support for the powerpc toolchain
-
arasium
- Posts: 6
- Joined: Fri Jan 29, 2010 1:28 pm
Post
by arasium » Mon Sep 20, 2010 2:22 pm
Hi everyone.
This code returns me a strange value.
Code: Select all
VPAD_Init();
struct mallinfo nfo = mallinfo();
struct mallinfo nfo2;
u32 length = 23801856;
cout << endl << endl << endl << "Memory used: " << nfo.uordblks << endl;
void* ptr = malloc(length);
nfo2 = mallinfo();
cout << "Allocated: " << nfo2.uordblks << endl;
cout << "Diff: " << nfo2.uordblks - nfo.uordblks << endl;
free(ptr);
nfo = mallinfo();
cout << "Memory used: " << nfo.uordblks << endl;
while(VPAD_ButtonsDown(0) == 0);
Can you explain me why the malloc reserved that amount of memory (and why it isn't freed at the end)?
-
WinterMute
- Site Admin
- Posts: 1986
- Joined: Tue Aug 09, 2005 3:21 am
- Location: UK
-
Contact:
Post
by WinterMute » Tue Sep 21, 2010 9:58 pm
uordblocks is the size of memory handed out by malloc, including any free blocks still in the malloc tables. fordblocks will tell you the size of the memory in free chunks which will be later used to satisfy malloc requests.
See
http://www.gnu.org/s/libc/manual/html_n ... alloc.html
Who is online
Users browsing this forum: No registered users and 2 guests