[NCLUG] Testing memory pressure
Chad Perrin
perrin at apotheon.com
Thu Jan 13 11:13:15 MST 2011
On Thu, Jan 13, 2011 at 10:04:19AM -0700, Bob Proulx wrote:
>
> Second you could use a very simple program to hog memory at whatever
> value you want. Here is a very simple one. Originally written to hog
> memory and push a machine into vm thrashing.
>
> Bob
>
> #include <stdlib.h>
> #include <stdio.h>
> main()
> {
> char *array;
<snip>
My first thought was "Make really really big arrays." That's pretty
simple to do in most languages, especially high level dynamic languages
like Perl and Ruby.
#!/usr/bin/env perl
my @foo;
foreach (1..$ARGV[0]) { push(@foo,$_); }
while (1) { sleep $ARGV[1]; push(@foo,'foo'); }
You can specify a starting array length with a command line argument, and
a wait time between additional elements being pushed into the array (in
seconds) with a second argument, with this version. Example:
./filename.pl 400 0.01
There's probably a more efficient way to do that, but since efficiency
isn't really the point in this case, I'm not sure it matters.
--
Chad Perrin [ original content licensed OWL: http://owl.apotheon.org ]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://lists.nclug.org/pipermail/nclug/attachments/20110113/fe0581fe/attachment.pgp>
More information about the NCLUG
mailing list