Found an interesting issue with flash.display.graphics.
When doing a lot of drawing with drawRect(), program was consuming more and more memory to the point where it rapidly crashed. I was using large bitmaps, so I thought they might be the cause of the issue. I set up the program to use the same bitmap over and over again and so eliminated that as the issue. I finally tracked it down to the drawRect() call which was very confusing since a draw routine does not normally consume memory.
Original function
public function Draw( backColor:int, hit:Boolean)
{
backColor = ( hit ) ? backColor: 0x000000;
_shape.graphics.beginFill(backColor);
_shape.graphics.lineStyle(1, 0x000000, 1);
_shape.graphics.drawRect( _x, _y, _size, _size);
_shape.graphics.endFill();
}
I researched this on the web and found a person who had run across the same issue and had solved it: Flash AS3: graphics.drawRect Memory Leak
Trick is to clear the graphics before using it each time as shown below!
Fixed function
public function Draw( backColor:int, hit:Boolean)
{
backColor = ( hit ) ? backColor: 0x000000;
//*****************************************************************
// need clear graphics or consume huge amounts of memory otherwise
_shape.graphics.clear();
//*****************************************************************
_shape.graphics.beginFill(backColor);
_shape.graphics.lineStyle(1, 0x000000, 1);
_shape.graphics.drawRect( _x, _y, _size, _size);
_shape.graphics.endFill();
}
Bottom line is that flash graphics are vector graphics and apparently use a new shape for each draw routine.
Note: this is technically not a memory leak…

By John Dorsey IT Brigade Inc.

Flash
as3, Flash CS4