Reputation: 21
I just have a question about memory allocation with ImageData in HTML. When you call createImageData, it apparently creates an Object. My question is, when does that object get deleted from memory, and is there a function to delete such objects? If not, would using it in a function with a local variable delete the object on the functions exit?
Thanks
Upvotes: 0
Views: 323
Reputation: 5685
It will be deleted when there are no references to it and it goes out of scope, so yes a local variable in a function would be freed when the function returns (so long as you haven't created a reference to it elsewhere). You can free it early by assigning the object null.
Upvotes: 3