"addDestroyCallback" in pin behavior

For developers using the Construct 2 Javascript SDK

Post » Tue Dec 27, 2011 12:41 am

I'm interested in "addDestroyCallback" in pin behavior.
I found that each pin behavior will push a function object to runtime's "destroycallbacks" array through "addDestroyCallback". Function object array "destroycallbacks" will be executed when each object destroyed.

When pin behavior had been destroyed, the callback in "destroycallbacks" will never been removed.
If I create many many pin behaviors, these might insert many many function objects into "destroycallbacks" array and never remove it. It's not a bug, just a little ... drawback.rexrainbow2011-12-27 00:44:23
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568

Post » Wed Dec 28, 2011 1:59 am

Oops, you're right - this is actually a small memory leak. I've added a 'removeDestroyCallback' for the next build and updated all behaviors that use it to also call that when they're destroyed. Thanks for the heads up!
Scirra Founder
B
402
S
238
G
89
Posts: 24,644
Reputation: 196,095

Post » Wed Dec 28, 2011 2:54 am

"DestroyCallback" or "CreateCallback" may be useful in plugin.
For example, maintain a hash table to get instance from uid directly.
B
110
S
28
G
280
Posts: 4,488
Reputation: 156,568


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests