123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|644|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Off Topic -> PMC Memory Management

Sun, 16 Dec 2012, 05:16
spinal
if I reuse the same gfx in PMC like this -- $Tiles = new Image("image_name_here.png") -- to load different gfx each time a level loads, will there be any adverse memory effects? Or is it designed that the gfx will be overwritten without any leaking or other such mess?

-=-=-
Check out my excellent homepage!
Sun, 16 Dec 2012, 05:16
Jayenkai
*takes a stab at it*

Modern languages have fairly decent Garbage Collection. I'd suggest that DDs gone to great lengths to make sure his does, too. I imagine that if you no longer reference an image, it'll be erased from memory. Then it's up to everything else to handle the actual remaining memory, so it might differ based on system/browser configurations.

Personally, I'd cram the different images into a big array, and use that instead of reloading into the same variable, but that's just because of my extreme distrust of all things "Garbage Collection"!! No doubt DD will be here in a jiffy to shout at me for having even suggested such a thing

-=-=-
''Load, Next List!''
Sun, 16 Dec 2012, 20:32
JL235
The old object will be garbage collected the moment it can no longer be accessed.

If you can get to it, it takes up memory. If you cannot, it doesn't.

Oh, except for sounds. They do need to be freed (it's a limitation of the library being used).
Sun, 16 Dec 2012, 23:26
steve_ancell
So would I be right in saying that if I wanted to put a tempory image inside of a function/def then it will automatically be disposed of once the function has done its stuff and been exited just like any local variable would?.
Mon, 17 Dec 2012, 04:32
JL235
Yes.

Although if you return the image, or assign to something, then it will stay around. But otherwise, yes, it'll automatically just be garbage collected.

This is also not a Quby/PMC thing, this is built into JS. So there is no added overhead.