How to fill 90% of free memory?
unix.stackexchange.com
unix.stackexchange.com
I believe at one point someone was able to actually install a game into the RAM Drive and play it on the left over available RAM but it required a game that could be installed and played without a reboot.
Anyway, my "clever" solution back then had been to fill up my disk enough before the install so that the setup would detect more free space.
dd if=/dev/zero of=/dev/shm/fill bs=1k count=1024k
(option #2 is to limit the amount of ram available to the kernel via grub.conf, see my comment below)Maybe creating a VM with just as much memory as the target system would be a better solution to get more predictable results?
Probably easiest way if you want low memory without fiddling.
mem=1G
mem=512M
etc. mem = 512
before rebooting. Ever since then, I know why my primary school teacher always got pissed when we left off the units :-)On a related note: Yes. The kernel needs more than 512 bytes of RAM to boot - even back in the 2.2 days (when this took place)
swapoff -a #include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void) {
int i;
char *p;
/* intro message */
printf("Starting ...\n");
/* loop 50 times, try and consume 50 MB of memory */
for (i = 0; i < 50; ++i) {
/* failure to allocate memory? */
if ((p = malloc(1<<20)) == NULL) {
printf("Malloc failed at %d MB\n", i);
return 0;
}
/* take memory and tell user where we are at */
memset(p, 0, (1<<20));
printf("Allocated %d to %d MB\n", i, i+1);
}
/* exit message and return */
printf("Done!\n");
return 0;
}
[1] http://sysadmincasts.com/episodes/14-introduction-to-linux-c...if I leave it on over the weekend hooked up to a few of my vm hosts, then I've got about 9gb ram used.
(Granted, I haven't noticed it happening quite as much with the latest version in Fedora 19, maybe some of the issues have been fixed?)
I have 32GB ram so I can cope, but calling out Firefox as the worst offender in class is a wee bit rich.
I think the story is that Firefox uses less, but because Chrome has an individual process for each tab they don't all die at once, and Chrome has a nicer about:memory page.
I've tried using lighter browsers like Midori but can't get away from having 10+ extensions for various things.
That said and done, I've had firefox run for several days on my computer and reach up to 3-4GB of memory used (I have 8GB). At that point it becomes very clunky and requires a restart.
I imagine most StackExchange posts here are because people might be interested in the answers rather than know them already.
http://stackoverflow.com/q/1229241/25981
In this case the user wanted the program to run out of memory and the best solution I could come up with was to use ulimit, to limit the amount of memory available to the process.
Option 2: Quick C program, but two gotchas: make sure you touch every page after allocating (and keep touching it, otherwise they will be swapped out)
(Also turning off or limiting swap space may be helpful)