Available memory?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Shapyi
Posts: 95
Joined: Mon Apr 25, 2005 9:31 am

Available memory?

Post by Shapyi »

I wrote a basic program that uses the graphics source code from Lua Player (graphics.h) and I am using psplink to play around. Before running the code I run "meminfo" and get:

Code: Select all

Memory Partitions:
N |    BASE    |   SIZE   | TOTALFREE |  MAXFREE  | ATTR |
--|------------|----------|-----------|-----------|------|
1 | 0x88000000 |  3145728 |    410112 |    396288 | 000C |
2 | 0x08800000 | 25165824 |  25069056 |  25069056 | 000F |
3 | 0x88000000 |  3145728 |    410112 |    396288 | 000C |
4 | 0x88300000 |  1048576 |   1048576 |   1048576 | 000C |
Then I run the program, load a small image (32 x 32 jpeg) and get:

Code: Select all

Memory Partitions:
N |    BASE    |   SIZE   | TOTALFREE |  MAXFREE  | ATTR |
--|------------|----------|-----------|-----------|------|
1 | 0x88000000 |  3145728 |    403968 |    396288 | 000C |
2 | 0x08800000 | 25165824 |   1209856 |    951808 | 000F |
3 | 0x88000000 |  3145728 |    403968 |    396288 | 000C |
4 | 0x88300000 |  1048576 |   1048576 |   1048576 | 000C |
Where did all the memory go? How did it go from 25,069,056 bytes to a mere 1,209,856 bytes? I tried just initializing the the graphics and loading no images and got:

Code: Select all

Memory Partitions:
N |    BASE    |   SIZE   | TOTALFREE |  MAXFREE  | ATTR |
--|------------|----------|-----------|-----------|------|
1 | 0x88000000 |  3145728 |    403968 |    396288 | 000C |
2 | 0x08800000 | 25165824 |  23298560 |  22088704 | 000F |
3 | 0x88000000 |  3145728 |    403968 |    396288 | 000C |
4 | 0x88300000 |  1048576 |   1048576 |   1048576 | 000C |
Is 'meminfo' accurate and the graphics code just wastes 20+ MB of RAM just to load a simple image? Is there any other way to get an accurate reading of the available memory?

Thank you.
weltall
Posts: 310
Joined: Fri Feb 20, 2004 1:56 am
Contact:

Post by weltall »

depending on how your application is done it could be malloc alloching all the available ram to manage it by itself: in this case you won't be able to get from system runtimes the status of the ram. there were some little function who did little malloc operations till fulfilling the alloched block to get the size allocable (and so the size available trough malloc). obviously if this is the case the maximum you can use trough malloc is the size which you found missing
Post Reply