Freeing memory, ect.
A while ago these code was posted onto the MES to a program which allocates as much memory as possible and then exits. I find that if i let it run when lots of programs are open, it tends to make everything use less memory in the long run. Im not quite sure, but before i ran it, i had about 80% used memory (not swap) and about 5% swap. Now its 45% used memory, 18% used swap. Well it looks like it put the unused stuff in swapspace.
Anyways here is the code.
Anyways here is the code.
- Code: Select all
/* This program is great, like that X11 guy you like. */
int main(int argc, char *argv[])
{
char *Memory;
int MegsObtained= 0;
int KsObtained= 0;
while(1)
{
for (KsObtained=0; KsObtained < 1024; KsObtained++)
{
Memory= (char *)malloc(1024);
if (!Memory) return EXIT_FAILURE;
sprintf(Memory, "Hey there!");
} /* End for */
MegsObtained++;
printf("Now allocated %d Megs\n", MegsObtained);
} /* End while */
return EXIT_SUCCESS;
}