"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
97
S
22
G
178
Posts: 4,121
Reputation: 104,049

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
359
S
214
G
72
Posts: 22,952
Reputation: 178,600

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
97
S
22
G
178
Posts: 4,121
Reputation: 104,049


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests