Free memory testers8/4/2023 Note: having 512GB physical ram for example, and if you tmpfs more than 512gb it will work, and allow you freeze/crash the system by allocating 100% of the RAM. Use free -g to observe how much RAM is allocated. # do 450 times 450 GB of 512GB approx 90% Obtain or copy or create a file of reasonable size create a 1GB file for example then cp my1gbfile /ramdisk/file001 # change 500G to whatever size makes sense in my case my server has 512GB of RAM installed. Mount -t tmpfs -o size=500G tmpfs /ramdisk ![]() The one downside is you need to be root to use the mount command # first as root make the given folder, however you like where the tmpfs mount is going to be. This will map RAM to a folder in linux, and then you just create or dump however many files of whatever size in there to take up however much ram you want. In case there are not enough answers already, one I did not see is doing a ramdisk, or technically a tmpfs. I need to have 90% of the free memory full Why another answer? The accepted answer recommends installing a package (I bet there's a release for every chipset without needing a package manager) the top voted answer recommends compiling a C program (I did not have a compiler or toolchain installed to compile for your target platform) the second top voted answer recommends running the application in a VM (yeah let me just dd this phone's internal sdcard over usb or something and create a virtualbox image) the third suggests modifying something in the boot sequence which does not fill the RAM as desired the fourth only works in so far as the /dev/shm mountpoint (1) exists and (2) is large (remounting needs root) the fifth combines many of the above without sample code the sixth is a great answer but I did not see this answer before coming up with my own approach, so I thought I'd add my own, also because it's shorter to remember or type over if you don't see that the memblob line is actually the crux of the matter the seventh again does not answer the question (uses ulimit to limit a process instead) the eighth tries to get you to install python the ninth thinks we're all very uncreative and finally the tenth wrote his own C++ program which causes the same issue as the top voted answer. x | head -c BYTES | tail ( yes outputs an infinite amount of "yes"es, tr substitutes the newline such that everything becomes one huge line and tail needs to keep all that in memory).Īnother, simpler alternative is using dd: dd if=/dev/zero bs=1G of=/dev/null uses 1GB of memory on GNU and BusyBox, but also 100% CPU on one core.įinally, if your head does not accept a suffix, you can calculate an amount of bytes inline, for example 50 megabytes: head -c $((1024*1024*50))Ĭredits to falstaff for contributing a variant that is even simpler and more broadly compatible (like with BusyBox). If you do not have a /dev/zero device, the standard yes and tr tools might substitute: yes | tr Just inserting the | pv | part will show you the current status (throughput and total by default). Of course this can also be done with previous variants: you have pv and want to slowly increase RAM use: To just quickly run out of RAM completely, you can remove the limiting head part: tail /dev/zero ![]() For a more precise amount, you will need to check how much RAM head and tail itself use on your system and subtract that. The line, read from /dev/zero which outputs only null bytes and no newlines, will be infinitely long, but is limited by head to BYTES bytes, thus tail will use only that much memory. This works because tail needs to keep the current line in memory, in case it turns out to be the last line.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |