Tag Info

Hot answers tagged

77

You can write a C program to malloc the required memory and then use mlock() to prevent the memory from being swapped out. Then just let the program wait for keyboard input, and unlock the memory, free the memory and exit.


42

I would suggest running a VM with limited memory and testing the software in that would be a more efficient test than trying to fill memory on the host machine. That method also has the advantage that if the low memory situation causes OOM errors elsewhere and hangs the whole OS, you only hang the VM you are testing in not your machine that you might have ...


38

stress is a workload generator that simulates cpu/mem/io/hdd stress on POSIX systems. This call should do the trick on Linux: stress --vm-bytes $(awk '/MemFree/{printf "%d\n", $2 * 0.9;}' < /proc/meminfo)k --vm-keep -m 1 Adapt the /proc/meminfo call with free(1)/vm_stat(1)/etc. if you need it portable.


26

run linux; boot with mem=nn[KMG] kernel boot parameter (look in linux/Documentation/kernel-parameters.txt for details).


20

From this HN comment: https://news.ycombinator.com/item?id=6695581 Just fill /dev/shm via dd or similar. swapoff -a dd if=/dev/zero of=/dev/shm/fill bs=1k count=1024k


20

Simply switch your repos to testing and do a full upgrade: # cp /etc/apt/sources.list{,.bak} # sed -i -e 's/ \(stable\|wheezy\)/ testing/ig' /etc/apt/sources.list # apt-get update # apt-get --download-only dist-upgrade # apt-get dist-upgrade Make sure you stay plugged in for the duration of the last command, though. If it's botched or incomplete and you ...


10

How about ramfs if it exists? Mount it and copy over a large file? If there's no /dev/shm and no ramfs - I guess a tiny C program that does a large malloc based on some input value? Might have to run it a few times at once on a 32 bit system with a lot of memory.


7

If you want to test a particular process with limited memory you might be better off using ulimit to restrict the amount of allocatable memory.


7

I keep a function to do something similar in my dotfiles. https://github.com/sagotsky/.dotfiles/blob/master/.functions#L248 function malloc() { if [[ $# -eq 0 || $1 -eq '-h' || $1 -lt 0 ]] ; then echo -e "usage: malloc N\n\nAllocate N mb, wait, then release it." else N=$(free -m | grep Mem: | awk '{print int($2/10)}') if [[ $N -gt $1 ]] ...


5

From the bash(1) man page: -n Read commands but do not execute them. This may be used to check a shell script for syntax errors. This is ignored by interactive shells.


5

To simply see if a drive can be read, you can use dd(1). This will read in the contents of the CDROM and will ignore/discard the data (note that the CDROM device may have another name on your system): dd if=/dev/cdrom of=/dev/null It is also possible to compare this to an ISO image: dd if=/dev/cdrom | md5sum - /path/to/file.iso This will print a ...


4

As for the tutorial, search engines seem to work, e.g. this one on howtoforge.com seems to give reasonable hints. Generally you might want to reconsider what exactly you are trying to achieve in the end. While eCryptfs will (to some degree) guarantee confidentiality you should be aware of several things: to hide the contents of home directory from other ...


4

For a low-level check, I found qpxtool. With my drive (which, to be fair, is not on the supported devices list), the results didn't make sense, but maybe you will have better luck.


4

Try out: dd if=/dev/urandom | bzip2 -9 >> /dev/null or use stress, a tool specifically designed to impose load on and stress test systems. It will launch multiple, parallel jobs and occupy 100% of your CPU: stress --cpu 8 --io 4 --vm 2 --vm-bytes 128M --timeout 10s


3

How abount a simple python solution? #!/usr/bin/env python import sys import time if len(sys.argv) != 2: print "usage: fillmem <number-of-megabytes>" sys.exit() count = int(sys.argv[1]) megabyte = (0,) * (1024 * 1024 / 8) data = megabyte * count while True: time.sleep(1)


3

You can use dmsetup to create a device-mapper device using either the error or flakey targets to simulate failures. dmsetup create test --table '0 123 flakey 1 0 /dev/loop0' Where 123 is the length of the device, in sectors and /dev/loop0 is the original device that you want to simulate errors on. For error, you don't need the subsequent arguments as it ...


3

Ecryptfs stores each encrypted file in one file (the lower file, in ecryptfs terminology). The directory structure of the lower files mirrors that of the payload files, although the file names are encrypted. The metadata (modification times, in particular) of the lower files also reveals that of the payload files. The size of the lower file is slightly ...


3

ttcp is a simple, possibly too simple, speed test utility. pchar is another one people cite a lot, I've had bad luck with it, personally. Here's how I'd use ttcp. You need two machines, each with ttcp (http://playground.sun.com/pub/tcp-impl/ttcp/ttcp.c) compiled on them. HostA % ./ttcp -r -s -p 9401 ... HostB % ./ttcp -s -p 9401 < /boot/vmlinuz ...


3

You might be interested in TeSpeed. It is described as: If you are looking for tool that is able to test internet connection speed fron Linux terminal, you have found it! :) TeSpeed uses speedtest.net servers to check upload and download rate and it puts that information on charts. http://tespeed.sourceforge.net/


3

Not that I know of, but you can force it to swap just by allocating (and using) some ram. #include <stdlib.h> #include <string.h> #include <stdio.h> int main(int argc, char **argv) { if (argc < 2) return 1; int megs = atoi(argv[1]); if (megs <= 0) return 2; int i; for (i=0; i<megs; i++) { ...


3

I'm just repeating the answers listed on this (deleted?) stackoverflow question: http://stackoverflow.com/questions/426272/how-to-test-internet-connection-speed-from-command-line k2z: wget --output-document=/dev/null http://speedtest.wdc01.softlayer.com/downloads/test500.zip or git clone https://github.com/sivel/speedtest-cli cd speedtest-cli ...


3

Following KISS principle, I'd just monitor free memory with free -m trying to run the same set of user apps for the same period of time. Just keep in mind, that 'cached' is actually free memory as well, so you need the 2nd line which shows what real used and free memory volumes are. Regarding CPU — WMs usually don't hog CPU by themselves — they do that ...


3

I think this is a case of asking the wrong question and sanity being drowned out by people competing for the most creative answer. If you only need to simulate OOM conditions, you don't need to fill memory. Just use a custom allocator and have it fail after a certain number of allocations. This approach seems to work well enough for SQLite.


3

Simple answer: No. tmux does not use unit tests or something like a big automated test suite. Also there is no check target or something similar in the Makefile. Anyhow there are some files which support a quick non automated test under /tools/, for example: /tools/UTF-8-demo.txt which contains a lot of UTF-8 ASCII Art examples /tools/256colors.pl which ...


2

So you hit upon the key here, if curl's output is different then you can test for it. First you can direct that to a file. Next you can leverage the -s option from test: -s file True if file exists and has a size greater than zero. Here is some example code: curl -b cookies.txt ... -o /tmp/curl_output if [ -s /tmp/curl_output ]; then do ...


2

you can do 2 things.. check /var/log/cron to check if it's being executed add > /tmp/log 2>&1 to the end of the cron entry. then cat /tmp/log to check if the output is correct.


2

You want a fault injection mechanism for I/O. On Linux, here's a method that doesn't require any prior setup and generates an unusual error (not EIO “Input/output error” but ESRCH “No such process”): cat /proc/1234/mem where 1234 is the PID of a process running as the same user as the process you're testing, but not that process itself. Credits to ...


2

You could use the expect tool to run programs in the VM. expect is a program that uses Tcl as it's scripting language, and extends the language a bit. It's been a long while since I've used expect, but I recall it being a bit inobvious as far as how to get some things to happen. It did have the capability of randomly spacing the timing of "typing" done by ...


2

OpenSuSE Build Service supports automatic build for many distributions (opensuse, ubuntu, ...). I heard that svn (or git) integration projects exist but I never used them. P.S. osc can be fully controlled by command line, so you could easily write an svn post commit hook (or git equivalent) to start the compilation.


2

I wrote this little C++ program for that: https://github.com/rmetzger/dynamic-ballooner The advantage of this implementation is that is periodically checks if it needs to free or re-allocate memory.



Only top voted, non community-wiki answers of a minimum length are eligible