checking how much memory is left psplink

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

Moderators: cheriff, TyRaNiD

Post Reply
coolkehon
Posts: 355
Joined: Mon Oct 20, 2008 5:44 am

checking how much memory is left psplink

Post by coolkehon »

i want to see how much memory is available on while using psplink how can i do this that way i can monitor how much my app is using and how much is free also as a note it uses alot of prx's so those each have some memory

i tried this but dont understand it

Code: Select all

meminfo
Memory Partitions:
N  |    BASE    |   SIZE   | TOTALFREE |  MAXFREE  | ATTR |
---|------------|----------|-----------|-----------|------|
1  | 0x88000000 |  3145728 |    298752 |    279808 | 000C |
2  | 0x08800000 | 25165824 |  12107264 |  11914752 | 000F |
3  | 0x88000000 |  3145728 |    298752 |    279808 | 000C |
4  | 0x88300000 |  1048576 |   1048576 |   1048576 | 000C |
5  | 0x08400000 |  4194304 |   4194304 |   4194304 | 000F |
6  | 0x08800000 | 25165824 |  12107264 |  11914752 | 000F |
11 | 0x88000000 |  3145728 |    298752 |    279808 | 000C |
hrimfaxi
Posts: 20
Joined: Thu Nov 23, 2006 5:40 pm

Post by hrimfaxi »

You can mesaure free space by allocating heap memory until malloc failed:

Code: Select all

unsigned int get_free_mem(void)
{
        void *p[30];
        unsigned int block_size = 0x04000000;   
        unsigned int block_free = 0;
        int i = 0;

        while ((block_size >>= 1) >= 0x0400)
        {
                if (NULL != (p[i] = malloc(block_size))) {
                        block_free |= block_size;
                        ++i;
                }
        }
        if (NULL != (p[i] = malloc(0x0400)))
        {
                block_free += 0x0400;
                ++i;
        }
        while (i--) {
                free(p[i]);
        }
        return block_free;
}
Kreationz
Posts: 52
Joined: Sun May 18, 2008 11:01 am

Post by Kreationz »

Thx, I can use this to test for leaks... by checking after each ROM is run and then storing the free amount in a global and then checking the difference. By looking at the difference it should give my the size lost which would tell me at least partially where the leak is. As well as how much I have to work with for the buffers.
Post Reply