PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

Memory

After loading bmp image of size 640x3072 by calling:
s_image->LoadImage(IDR_IMAGE),
application takes 9Mb RAM memory. Is that normal?
I mean 640*3072/1024/1024 == 1,86Mb. Have I missed something?
Squirrel wrote:After loading bmp image of size 640x3072 by calling:
s_image->LoadImage(IDR_IMAGE),
application takes 9Mb RAM memory. Is that normal?
I mean 640*3072/1024/1024 == 1,86Mb. Have I missed something?

Actually, it's 640*372*2, since each pixel is 2 bytes (16bit color). That equals 3,932,160 bytes, which is closer to 4 megs. But you've also got to remember that it loads the image, then copies it into a Surface object, then frees the original memory, so for a moment it's in the memory twice. So, that memory that it freed is most likely still allocated/available to the application, but it's really only using the 4megs for the Surface.
Thanks for explanation, I was afraid it's some kind of bug. Is there any way to combat that problem? 3-4 images of this size make game imposible to run since they require too much memory.
Anonymous wrote:Thanks for explanation, I was afraid it's some kind of bug. Is there any way to combat that problem? 3-4 images of this size make game imposible to run since they require too much memory.


Obvious solution: Split them up into smaller files :).
If you use the XP/2000 taskbar - it won't give you any good numbers about what will happen on PPC.

640*3072[B]*2 bytes per 565 color[B]*/1024/1024 == 3,75MB

Do you measure it on PPC?
I hope you won't load this big surface at once in your game (you use it for testing purposes only) ;)
On PPC result is even worst (more memory). Since I use 256 color pallete, editing Surface class could help.

BIGBEN wrote:
I hope you won't load this big surface at once in your game.

By the way, I did :lol: . But I need all that images to be loaded and used at one time. Would splitting them up help in that case?
Squirrel wrote:On PPC result is even worst (more memory). Since I use 256 color pallete, editing Surface class could help.


Cool, it is a very good idea. If you manage to do it, please contribute ;)
How do you measure the space occupied by the program on a PPC?
What version of PHal do you use?

Release 0.7.6c
==============

All platforms:

- Fixed memory allocation issue with surfaces (too much memory was consumed).
I use 0.7.7 PHal version (Still, splashscreen shows 0.7.3, what that could be?).

I haven't realy measured ocupied memory on PPC :wink:, it's just my guess, couse on desktop while the game is active, it is ocuping about 28 megs, and on PPC with 36 Mb free memory it didn't even run. Thought, there could be another reason.
If the splashscreen is showing 0.7.3, you need to update it. Download the latest and overwrite the PocketHAL_xxx.lib files. (xxx=ARM, x86, EMU, etc.)

-John
I've found the problem - it was just me ;). Lib files are located in subfolders in update archive, but I didn't notice that and just copied them in my PocketFrog folder.
After update memory appetite of my game came down from 24Mb to 15Mb. Quite decent.