forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

checking how much memory is left psplink

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
coolkehon



Joined: 20 Oct 2008
Posts: 355

PostPosted: Wed Jul 01, 2009 8:28 am    Post subject: checking how much memory is left psplink Reply with quote

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:
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 |
Back to top
View user's profile Send private message MSN Messenger
hrimfaxi



Joined: 23 Nov 2006
Posts: 22

PostPosted: Wed Jul 01, 2009 6:44 pm    Post subject: Reply with quote

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

Code:

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;
}
Back to top
View user's profile Send private message
Kreationz



Joined: 18 May 2008
Posts: 53

PostPosted: Fri Jul 03, 2009 6:27 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group