Loading a 100MB PNG and draw it on the canvas but it eats 1GB of RAM :(

Hello,

There are tools that you can use to monitor memory usage such as VisualVM:
https://visualvm.github.io/

I found this Java.lang.Runtime class useful to monitor memory usage:

I created a couple of images in different formats (JPG and PNG) that were 15000x7000 in image size in pixels which is not the same as image size of the file.

The image size of the file is in the comments in the code below and here:

Results:

The size in memory is the same and it makes no difference if it is a JPG or PNG file.

I did NOT check this and set a size in Preferences for testing:
image

If you do set the maximum available memory give consideration to memory usage for your program and how much memory you have on your system.

I have 16GB and had memory available.

References:

:)

2 Likes