1
\$\begingroup\$

I am calling kill() and destroy() on flxText when i dont need it anymore, how come its still using the memmory it let the game run for a while it went up to 1,5 gig of ram, then i commented it out the code where flxText is made and got this http://shrani.najdi.si/?3u/x6/1MkFPi08/fac.png (using only 170m-190m), so its obviously flixel text not cleaning up propperly , wat do ?

\$\endgroup\$
2
\$\begingroup\$

Hi Matthew and thank you for your question.

Since ActionsScript uses garbage collection there are only 2 reasons.

First you have references to these objects in your own objects or from a manager in fixel. In this case be aware to null your references. Maybe the tool mentioned here could be useful.

Second your garbage collection did not trigger automatically. In this case force it to clean up. Sometimes garbage collection can not or need many attempts to free all memory. This is caused by circular references. I.e. A references B and B references A and you null the reference to A.

So what to do. Check if you really null your references and that no reference is left from your side of code. If the problem continuous check if flixel tracks some references internally and lookup how to remove them. If the problem is not solved check for objects that reference each other. Normally this should not cause this problem because garbage collection checks for circular references.

I hope I could help you. Have further questions?, please tell us. Michael

\$\endgroup\$
  • \$\begingroup\$ I make a variabile text via function like this pastebin.com/A0U67d8F , will each var text refrence still exist and point to the new Text that i made even after function ends ? \$\endgroup\$ – Matthew Nov 28 '13 at 14:52
  • \$\begingroup\$ No the reference to the new object is just on the stack and deleted with the end of your method. Anyway if you call this to often in reputation this can cause a huge amount of memory used. You shall initialize your content ones and change its properties not create every time a new one. \$\endgroup\$ – NjamNjam Nov 28 '13 at 20:11
1
\$\begingroup\$

So what i did to fix this is, i made 10 variabiles in advance and made the code check if there are any dead ones first, and then just revive the dead one. Recycling 10 objects forever fixed the leak

\$\endgroup\$
  • \$\begingroup\$ If you're using something like flashdevelop you can use the profiler next time. \$\endgroup\$ – Sidar Nov 30 '13 at 22:35
  • 1
    \$\begingroup\$ FYI: This is caller object pooling. \$\endgroup\$ – Vaughan Hilts Dec 18 '13 at 22:27
1
\$\begingroup\$

I've found it helps to set all references for objects to null on destroy.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.