LOADSPRITE and Memory

Previous topic - Next topic

Hemlos

Heyas

Im having an issue with loading images, and my ram being wiped out.
Is there something about LOADSPRITE that im not aware of?

i have 8 gigs of ram installed.
The os uses 2 gig, the program uses about 4 gig, and the gpu is using 2 gig of onboard ram.

When i load about 38 images of around 1mb~2mb each, jpg format, my program ends.
This group of images total about 45 mb.
The windows7 os complaining about resources being depleted, and the program is forced to shutdown.
I was watching my task manager, and i noticed well over 4 gig of ram is being used up by the program, very odd.
The ram was disappearing slowly as the program loads each of the images....it takes about a minute to get to #38 image.

Thats about 1 gig of ram being used for roughly 8 images.




Bing ChatGpt is pretty smart :O

erico

Could it be because GLB internally stores the images as an uncompressed format + alpha?
How big is one of those images?

Hemlos

Each images is less that 2 mb.
Bing ChatGpt is pretty smart :O

fuzzy70

What are the image dimensions? for example a HD 1920x1080 works out about 8MB of memory usage, where as a 12MP digital camera image takes up 47MB.

Jpeg file sizes can be misleading, for example a 2MB jpeg image could have a low resolution & low compression or have a high resolution with high compression.

Perhaps the decompression of the jpg may be affecting things?

Lee.

"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

erico

Yep, that is what I meant too...what is the size of the image in pixels x pixels?

Hemlos

I think youre right, to a certain degree, the images are 3072x3072 96dpi  24bit

So one image is about 27mb as a BMP conversion.

This is still not really explaining the 4 gig usage...im calculating the size now...about 1 gig for the 38 images....not 4gb as windows taskmanager is showing.

30mb x 38 = 1140mb

Bing ChatGpt is pretty smart :O

erico

#6
hmmm...even if you add another 8bit for internal transparency, it would still no reach that, as 36mb per image.
I don´t know what to think, are your jpgs RGB or CMYK? Do they have extra stuff, like guides and paths into them?

edit: can you post an image sample zipped?


spacefractal

glbasic is a 32bit application, so its property crashout when its try to allcoate more than 2gb ram. This is the typical limit on a Windows application. Few applications is designed to uses 3gb ram in a 32bit app, but im dont thinks glbasic is designed for that.

howover is glbasic is compiled as 64bit application, its can uses much more ram.

LOADSPRITE with very big texture and pictures take a lots of ram, since its uses 4 bytes per pixel.
Genius.Greedy Mouse - Karma Miwa - Spot Race - CatchOut - PowerUp Elevation - The beagle Jam - Cave Heroes 2023 - https://spacefractal.itch.io/

erico

Well thought! That should be the reason me guesses. So it would probably be best Hemlos loads images in batches.

fuzzy70

GLB being a 32bit program did cross my mind but I discounted it mainly because each image is around 37MB in raw RGBA for, multiply that by 38 images equals 1.4GB of space so under the 2GB win32 limit imposed on by most win32 apps.

However I done a simple test listed to below just to see memory usage out of curiosity & saw things I didn't really expect to see. The images loaded are the size the filename says, so 1024k is a 1024x1024 image etc & the images are just simply rendered clouds from photoshop to give some randomness to them.

The program starts using 12,916KB of ram before loading the 1st image, then jumps to 25,536 after image has loaded (1024k one). The next image uses 58k then drops to 38K but pagefile size increases, then 142K ram, 168K ram then finally 563K. After every LOADSPRITE the ram increases as stated earlier but as soon as the image is displayed on screen it drops down to 38K & pagefile usage increases. At one point (on the last image) the page file increases to over 1GB higher before running the program then drops down just over 320MB from initial.

All the images combined add up to around 376MB in raw RGBA form yet system ram reports only 38MB used, adding the page file increase gets me around the 376MB as expected.

What causes the big ram jump in the 1st place I have no idea other than possible jpg decompression, also why the pagefile usage is beyond me but expect nothing less from M$ & their never ending addiction to using the pagefile.

Lee

Code (glbasic) Select
SETCURRENTDIR("Media") // go to media files

SETSCREEN 800,600,0
KEYWAIT
LOADSPRITE "1024k.jpg",1
DRAWSPRITE 1,0,0
SHOWSCREEN
KEYWAIT
LOADSPRITE "2048k.jpg",2
DRAWSPRITE 2,0,0
SHOWSCREEN
KEYWAIT
LOADSPRITE "3072k.jpg",3
DRAWSPRITE 3,0,0
SHOWSCREEN
KEYWAIT
LOADSPRITE "4096k.jpg",4
DRAWSPRITE 4,0,0
SHOWSCREEN
KEYWAIT
LOADSPRITE "8192k.jpg",5
DRAWSPRITE 5,0,0
SHOWSCREEN
KEYWAIT
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

MrTAToad

I wonder if there is a problem with JPG decompression...  Could you make the files available ?

fuzzy70

Just done the same tests again but with BMP's & PNG's & witnessed exactly the same memory pattern as before.

I must mention that all tests where done with debug disabled so as to remove that from being a possible cause.

Pagefile usage in my case may be down to using 32bit windows 7 with 2GB of ram as my main machine is down at the moment. However it has 1.4GB free after booting windows & startup processes complete so more than enough free for the test program which shouldn't use more than 400MB inc the images.

Lee
"Why don't you just make ten louder and make ten be the top number and make that a little louder?"
- "These go to eleven."

This Is Spinal Tap (1984)

matchy

What happens if the process is replaced with a simulated CREATESCREEN, which only 32 can be created?  :|

Hemlos

Hmm, thanks for the help guys. And thanks for the testing.

ITs interesting, perhaps Gernot will drop by and give us some more input when he has a chance.

For now, i have resorted to images that are 10 times small as an alternative.
I will limit and use the hd images only when i need more info from them.

Heres the project i am working with right now so you guys can see what im doing....ps keep in mind, this is alpha stage, and it needs some optimizations...theres also a few more options that are not added yet...like frame count limiting how many frames will animate etc....
Any ideas to add to this are welcome, i will be publishing this program in the very near future.

-Neil

PS..the download is attached to this message.
Bing ChatGpt is pretty smart :O

erico

Juuuust tested, looking pretty good!
Are the original images from nasa a circle or a rectangle? You could map that to 3d maybe.
Everything worked out fine.

I had a crash on first run on my opengl card, probably related to resolution change or full screen.
Second time it got windowed and worked fine.