Playing around with Imaging API, I found this dispose() method which frees memory after using the .getData() method. However here’s the issue I found:
Here’s the link to the documentation error:
If you try to run the same code in the example:
const pixelData = await imageObj.imageData.getData();
pixelData.dispose();
// This will return an error: "pixelData.dispose is not a function"
Which is obvious as the getData()
method returns an array of numbers (image pixel data) and not an object, so the object is the imageObj.ImageData
and this can call the dispose()
function indeed to free the memory from the imageObj.imageData.getData();
How I know this?
I tried to do the imageObj.imageData.dispose()
method after storing the data obtained with the imageObj.imageData.getData()
it into a constant and it worked.
So I think this should be changed to
imageObj.imageData.dispose();
Instead of
pixelData.dispose();
So this is something that can be confusing for future developers reading the documentation.
Hope it gets clear enough.
Correct if I’m wrong, please.