Code to make the biggest and baddest memory leak possible?
Anyone have any code that can create huge memory leaks at ultra fast speeds?
I''m trying to test out a memory manager I recently purchased, and want to run some code that will generate some huge leaks.
Assuming you use C++, just create a simple class that allocates a random amound of memory using malloc() in it''s constructor.
Creata a few thousand instances in a loop, then destroy ''em.
Creata a few thousand instances in a loop, then destroy ''em.
#include <malloc.h>int main(){ while (1) char *c=(char *)malloc(1048576);}
-----------------------
0wn 0wn 0wn your goat
gently down the pw33n
This should work ( haven''t tested it ):
You could then just do something like:
CreateMemoryLeak( 0xffffffff ) to create a 4Gb memory leak, although that would quite possibly crash your system.
Death of one is a tragedy, death of a million is just a statistic.
void CreateMemoryLeak( int size_to_allocate ){ char *dummy = new char[size_to_allocate];}
You could then just do something like:
CreateMemoryLeak( 0xffffffff ) to create a 4Gb memory leak, although that would quite possibly crash your system.
Death of one is a tragedy, death of a million is just a statistic.
void CreateNastierMemLeak(long long size){ long long *evil = (long long*)malloc(sizeof(long long) * size);}
just to make it more evil, i used malloc
Edited by - barazor on January 1, 2002 4:06:39 PM
I see there''s a function called "HeapLock"... I wonder if this would screw the system over:
while(1) HeapLock(HeapCreate(0, 1024*1024, 0));
while(1) HeapLock(HeapCreate(0, 1024*1024, 0));
#include
int main() {
while (1)
fork();
}
If you were all stylin unix style.
If you want to test a memory manager, best thing would be to use annoying size memory blocks like
1025 bytes (instead of 1024) or
64536 bytes.. or ... the worst for a memory manager would be to keep allocating 1 byte at a time...
int main() {
while (1)
fork();
}
If you were all stylin unix style.
If you want to test a memory manager, best thing would be to use annoying size memory blocks like
1025 bytes (instead of 1024) or
64536 bytes.. or ... the worst for a memory manager would be to keep allocating 1 byte at a time...
c:\> copy con eat.bat
type eat.bat>>eat.bat
<F6>
c:\> eat<enter>
You could get really devious and launch processes recursively all at REAL_TIME priority.
Magmai Kai Holmlor
"Oh, like you''ve never written buggy code" - Lee
"What I see is a system that _could do anything - but currently does nothing !" - Anonymous CEO
type eat.bat>>eat.bat
<F6>
c:\> eat<enter>
You could get really devious and launch processes recursively all at REAL_TIME priority.
Magmai Kai Holmlor
"Oh, like you''ve never written buggy code" - Lee
"What I see is a system that _could do anything - but currently does nothing !" - Anonymous CEO
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement