IGTHORN wrote:
You could reuse your objects instead of letting them get garbage collected. So set things to be inactive rather than deleting them. Then when something new gets spawned, reactivate and reinitialise one of the inactive objects.
Allocating 4kb more memory every repaint sounds high. But as long as it eventually gets garbage collected, maybe its not worth worrying about. It's only a serious problem if you've somehow created a memory leak, where that 4kb of allocated memory never gets garbage collected.
Yeah, assuming he is using a canvas element, it would just be a matter of making one (or two if using a backbuffer) canvas element, and using that throughout the life of the script. For the vast majority of purposes, that would be fine... one would not need to worry about allocating and/or garbage-collecting such a thing.
Like I said, once we see code, we can see the issue.
