How can I deliberately reduce free memory in linux by a given amount? [closed] - linux

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am looking for a quick and dirty way to analyze how a memory intensive third party application behaves under reduced memory conditions and determine a "minimum viable free memory" threshold.
you#yours:~$ free
total used free shared buffers cached
Mem: 993M 879M 113M 1.1M 15M 116M
you#yours:~$ hogMem 100 &
you#yours:~$ free
total used free shared buffers cached
Mem: 993M 979M 13M 1.1M 15M 116M
you#yours:~$ date; runTheThing; date;
you#yours:~$ fg
you#yours:~$ ^C
you#yours:~$ free
total used free shared buffers cached
Mem: 993M 879M 113M 1.1M 15M 116M
In the above, what could I use for hogMem?
I hope to do it with existing commands, without getting into a complicated programming problem. Googling this issue gets me 1,000s of pages about how to get more free memory, not less.
Update 2016/04/28 :
So, I found a super convenient way to do this, thanks to the hint by #Cyrus
you#yours:~$ sudo mkdir -p /media/temporary_ram_disk
you#yours:~$ sudo mount -t tmpfs -o size=2048M tmpfs /media/temporary_ram_disk/
you#yours:~$ sudo chown you:you /media/temporary_ram_disk/
you#yours:~$ cd /media/temporary_ram_disk/
you#yours:/media/temporary_ram_disk$ free -h
total used free shared buffers cached
Mem: 993M 879M 113M 1.1M 15M 116M
you#yours:/media/temporary_ram_disk$ fallocate -l 100M empty_file_100M
you#yours:/media/temporary_ram_disk$ ls -l
total 5120
-rw-r--r-- 1 you you 5242880 Apr 28 12:05 empty_file_100M
you#yours:/media/temporary_ram_disk$ free -h
total used free shared buffers cached
Mem: 993M 879M 13M 1.1M 15M 116M
So the hogMem I'm using is in fact fallocate !

Probably the best way to see "how a memory intensive third party application behaves under reduced memory conditions," is to run it under reduced memory conditions. On linux, this is easily done with prlimit.
For example, to see how date runs with its address space limited to 1,000,000 bytes, run:
$ prlimit -v1000000 date
Segmentation fault
To see how it runs with its address space limited to 10,000,000 bytes, run:
$ prlimit -v10000000 date
Wed Apr 27 12:00:13 PDT 2016
It is also possible to limit the target program's access to many other resources. For example the maximum number of open files or the maximum CPU time can also be limited.
prlimit is included in the util-linux package. For more details on its operation, see man prlimit.

Related

Seems like I have lots of space outside of the boot disk but I can't install packages - how do I clear space? Ubuntu GCloud VM [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 11 months ago.
Improve this question
Here is the output of df -H. I keep deleting caches and tmp directories but the problem keeps resurfacing. Any tips on how I might clear out more space?
My home directory is only taking up 3GB - including Python packages and so on, not sure where the 104GB is being taken up. I deleted snapd earlier because all the loop devices were full with vnode tables; any time I try to install a package, for instance, xdiskusage, I get the error `
After this operation, 525 MB of additional disk space will be used.
E: You don't have enough free space in /var/cache/apt/archives/...
df -H
Filesystem Size Used Avail Use% Mounted on
/dev/root 104G 104G 0 100% /
devtmpfs 180G 0 180G 0% /dev
tmpfs 180G 0 180G 0% /dev/shm
tmpfs 36G 3.6G 33G 10% /run
tmpfs 5.3M 0 5.3M 0% /run/lock
tmpfs 180G 0 180G 0% /sys/fs/cgroup
/dev/sda15 110M 5.5M 104M 5% /boot/efi
tmpfs 36G 0 36G 0% /run/user/2002
Warning: you will not be able to log in to Linux when you run out of free disk space. Immediately delete some files or reside the disk larger.
The first step is to delete everything in the /tmp folder. Ignore warnings about not being able to delete files as some processes may have files open.
Next figure out what are the largest files and review which ones can be deleted.
This command will list the 25 largest files:
find / -type f -printf '%s %p\n'| sort -nr | head -25
Be careful what you delete. Do not manually delete files located in the OS directories.
Next list the largest installed packages. Uninstall any that are not required.
dpkg-query --show --showformat='${Installed-Size}\t${Package}\n' | sort -rh | head -25 | awk '{print $1/1024, $2}'
Another item is to review the largest directories on your system:
du -a / | sort -n -r | head -n 25
The final solution(s) are up to you. You must decide which files are not longer required for your system.

Ubuntu wrongly shows low disk space [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 4 years ago.
Improve this question
I installed Ubuntu 14.0 on virtual box. Initially I had allocated 10 GB for the .vdi. I increased it to 25 GB. When I check the size in the settings in virtual box, its showing correctly as 25GB. See below:
But I am frequently getting error warnings on Ubuntu for Low Disk Space.
I checked in System Monitor > File Systems and see that its not picking up allocated disk space and showing only the old 6.2 GB. See below :
What should I do to solve this? Please help.
I encountered the same problem...
Used the following to solve the problem:
vboxmanage modifyhd "/path/to/virtualdrive.vdi" --resize <NewSize>
open the virtual machine and resize the partition (easily done using gparted). The drive was resized to 100G
Then:
# df -h /home/
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/ubuntu--vg-root 24G 22G 1.1G 96% /
# lvextend -L +100G /dev/mapper/ubuntu--vg-root
Size of logical volume ubuntu-vg/root changed from 24.00 GiB (6145
extents) to 124.00 GiB (31745 extents).
Logical volume ubuntu-vg/root successfully resized.
# resize2fs /dev/mapper/ubuntu--vg-root
The filesystem on /dev/mapper/ubuntu--vg-root is now 32506880 (4k)
blocks long.
# df -h
Filesystem Size Used Avail Use% Mounted on
udev 3.9G 0 3.9G 0% /dev
tmpfs 798M 1.4M 797M 1% /run
/dev/mapper/ubuntu--vg-root 122G 22G 96G 19% /
df -h or your GUI system monitor app shows the actual FS characteristics, not the Volume size.
You should first check /dev/sda device, then ensure you can update /dev/sda1 volume size (fdisk or other software could be used for this purpose). And after that you should increase FS size using resize2fs utils.
Then you'll be able to use whole disk.
U should try "df -h" in terminal and see the big partitions and it's phat. After you use the "du -csh /phat/bing/" to see what file is so big and process it.

Unknown memory utilization in Ubuntu14.04 Trusty

I'm running Ubuntu Trusty 14.04 on a new machine with 8GB of RAM, and it seems to be locking up periodically and nothing is in syslog file. I've installed Nagios and have been watching the graphs, and it looks like memory is going high from 7% to 72% in just a span of 10 mins. Only node process are running on server. In top I found all process are running very normal memory consumption. Even after stopping node process. Memory remains with same utilization.
free agrees, claiming I'm using more than 5.7G of memory:
free -h
total used free shared buffers cached
Mem: 7.8G 6.5G 1.3G 2.2M 233M 612M
-/+ buffers/cache: 5.7G 2.1G
Swap: 2.0G 0B 2.0G
This other formula for totaling the memory roughly agrees:
# ps -e -orss=,args= | sort -b -k1,1n | awk '{total = total + $1}END{print total}'
503612
If the processes only total 500 MiB, where's the rest of the memory going?
I've got solution on this... so just wanna to update the same...
echo 2 > /proc/sys/vm/drop_caches
This resolved my issue. So I have added the same in my cron for every 5 mins on each of ubuntu server

Amazon EC2 micro instance - ran out of space? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
df -h shows that only 71% of space used:
root#ip-xxx-xxx-xxx-xxx:/home/myuser# df -h
Filesystem Size Used Avail Use% Mounted on
rootfs 7.9G 5.3G 2.2G 71% /
udev 10M 0 10M 0% /dev
tmpfs 60M 88K 60M 1% /run
/dev/xvda1 7.9G 5.3G 2.2G 71% /
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 120M 0 120M 0% /run/shm
However nothing can create a file anymore, even MC does not start
#mc
Cannot create temporary directory /tmp/mc-root: No space left on device (28)
Php can not create files
PHP Warning: fopen(/home/.../file.json): failed to open stream: No space
left on device in /webdev/www/..../my.php on line 10
What could it be?
I use Debian 7 on Micro instance.
df -h shows you disk free space in human readable format. But this sounds like an inode table issue which you can check via df -i. For example, here is my inode usage on my own Amazon ECS micro instance running Ubuntu 12.04:
Filesystem Inodes IUsed IFree IUse% Mounted on
/dev/xvda1 524288 116113 408175 23% /
udev 73475 379 73096 1% /dev
tmpfs 75540 254 75286 1% /run
none 75540 5 75535 1% /run/lock
none 75540 1 75539 1% /run/shm
Depending on the output, I bet your inode table is filled to the brim. The inode table logs each individual file data. Not just how much space. Meaning you might have 71% in use, but that 71% can be filled with thousands of files. So if you have tons of small files, you might still technically have free space, but the inode table is full so you have to clear that out to get your system fully functional again.
Not too clear on the best way to clear this up, but if you know of a directory that has tons of files you can toss away right away, I would recommend removing them first. For what it’s worth, this question & answer thread looks like it has some decent ideas.

What is equivalent of Linux's 'free' command on FreeBSD v8.1 [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
What is equivalent of Linux's 'free' command on FreeBSD v8.1?
I am calling 'free' from my application and reporting the results in my application's log file. What would be the replacement when porting to FreeBSD v8.1?
Here is a sample run of 'free' on Linux:
[centos4x32 ~] free
total used free shared buffers cached
Mem: 774452 733044 41408 0 98040 328880
-/+ buffers/cache: 306124 468328
Swap: 2031608 224 2031384
vmstat has default output which is similar in nature and takes many options that give extremely detailed information, eg vmstat -m
swapinfo would cover the swap part
top -d1 causes top to print one screen and exit, and the banner is very similar to free. Use top -d1 | head -n 7 to see only the banner
Maybe freecolor command is a choice. Install it:
# cd /usr/ports/sysutils/freecolor
# make install clean
Use it:
# freecolor
Physical : [#################################..] 94% (1907820/2018396)
Swap : [###################################] 100% (1048540/1048540)
# freecolor -m -o
total used free shared buffers cached
Mem: 1971 107 1863 0 0 0
Swap: 1023 0 1023
Please refer FreeBSD find out RAM size Including Total Amount of Free and Used Memory Size.
vmstat -s gives some more human-readable or script-parseable information, including listing the page size. Otherwise, it gives output in numbef of pages. With no options, vmstat gives a brief summary.
The vmstat command also exists on NetBSD.
just use old good htop
install htop
pkg install htop
to run
htop
Other option:
# vmstat fre
procs memory page faults cpu
r b w avm fre flt re pi po fr sr in sy cs us sy id
0 0 0 13475M 24M 689 1 2 0 344 394 14693 37734 60809 7 43 50
You can use this script.
# fetch http://www.cyberciti.biz/files/scripts/freebsd-memory.pl.txt
# mv freebsd-memory.pl.txt /usr/local/bin/free
# chmod +x /usr/local/bin/free
source: http://www.cyberciti.biz/faq/freebsd-command-to-get-ram-information/

Resources