stride icon indicating copy to clipboard operation
stride copied to clipboard

Unexpected large memory usage when using large images

Open mmujic2 opened this issue 2 years ago • 3 comments

Release Type: Official Release

Version: 4.1.0.1457

Platform(s): Windows

Describe the bug When adding large images (for example 3000x9000) stride memory usage spikes suddenly.

To Reproduce Steps to reproduce the behavior:

  1. Create empty project and add a sprite sheet asset.
  2. Add a sprite and select a large image (can be easily created using paint for example).

Expected behavior Memory usage shouldn't be this large, images with mentioned size can spike memory usage even by 1GB (Worst I got is 7GB total).

mmujic2 avatar Jul 10 '23 19:07 mmujic2

I only have a question? Why would anyone use images larger than 4096x4096 in the context of a game engine? What are you trying to achieve?

Anyway, assuming the image is using 4 bytes per pixel, (R,G,B,A, 8 bits per channel), your image should have: ( 3000 x 9000 ) x 4 bytes = 108,000,000 bytes = 105468.75 KB = 102.996826172 MB, if uncompressed.

You're right by saying that 7 GB allocated is too much. One could assume useless deep copying being made?

NicusorN5 avatar Sep 11 '23 00:09 NicusorN5

Reason I use higher resolution is because I have a scene setup where I slowly scroll through an image in the background, and thus I use images wider/higher than common monitor resolutions.

Also I have scaled the images down to 1500x4500, but the problem still persists, so I think there is something else that causes these memory spikes (I'd say any resolution of 1000+x1000+ can cause this problem).

mmujic2 avatar Sep 11 '23 07:09 mmujic2

I just tried this and wasn't able to reproduce it. Tried with both a 4096x4096, and a 3000x9000 colored static noise texture, imprted as a sprite sheet. Opened and edit the sprite sheets, and still didn't see any unexpected memory usage. Part of the issue might have been that having multiple open at once so they were all in memory. Another part of it mght be that because it isn't a power of 4 sized texture, it wasn't being compressed well.

MechWarrior99 avatar May 21 '24 02:05 MechWarrior99