I
ImpalerCore
What is the best way to exhaust a lot of memory but at the same time
leave enough so that I can test out of memory errors for some
container functions, i.e. like not having enough memory to allocate a
new list node.
So far, all I've done is something like:
const size_t block_size = 1024*1024;
size_t count;
for ( count = 0; malloc( block_size ); ++count );
....
The smaller the block_size, the longer it takes to exhaust memory. So
I plan to starting with a large block size, exhausting memory,
reducing the block size, exhausting memory, until I get down to a
level that I can exercise my out of memory error handling.
Is this a good strategy? Are there pitfalls that I'm not seeing?
Again, I'm assuming that ending the process reclaims the memory used.
leave enough so that I can test out of memory errors for some
container functions, i.e. like not having enough memory to allocate a
new list node.
So far, all I've done is something like:
const size_t block_size = 1024*1024;
size_t count;
for ( count = 0; malloc( block_size ); ++count );
....
The smaller the block_size, the longer it takes to exhaust memory. So
I plan to starting with a large block size, exhausting memory,
reducing the block size, exhausting memory, until I get down to a
level that I can exercise my out of memory error handling.
Is this a good strategy? Are there pitfalls that I'm not seeing?
Again, I'm assuming that ending the process reclaims the memory used.