Hot answers tagged

22

Don't try this at home! It can crash your system, and if you're really unlucky it could damage a peripheral or make your computer unbootable. Actually, on most platforms, it just fails with an error, but that depends on the hardware architecture. There is most definitely no guarantee that this is harmless unless you run the command as an unprivileged user. ...


13

It is safe, if you have properly configured kernel ( safe because it won't work ) Per manual page mem(4): /dev/mem is a character device file that is an image of the main memory of the computer. It may be used, for example, to examine (and even patch) the system. So in theory, dd if=/dev/urandom of=/dev/mem should overwrite whole ...


5

Linux does not do "opportunistic swapping" as defined in this question. The following primary references do not mention the concept at all: Understanding the Linux Virtual Memory Manager. An online book by Mel Gorman. Written in 2003, just before the release of Linux 2.6.0. Documentation/admin-guide/sysctl/vm.rst. This is the primary documentation of ...


2

Programs take all the memory and CPU power they can get, unless they have built-in limitations. unzip has no such built-in limitations. You could give it less, but you can't give it more, because by default it's allowed to take as much as it wants. Unzipping is not a memory-intensive process. The main memory cost of unzipping a huge archive is that unzip ...


2

Your observation is correct. The new string you have allocated with malloc replaces the old string, and the old string is not used anymore. If the old string is part of the environment passed when the program is started (i.e. this is the first time the variable is changed in this process), then the old string is part of the stack segment. If this is a ...


1

It's a shame that you've reworked your question from the first version which asked about setenv() because setenv() does leak memory, at least in the glibc implementation. Take this example program; it will grow and grow until it eats up all the memory it can: #include <stdlib.h> #include <stdio.h> int main(void){ char buf[24]; ...


1

(since I cannot add a comment to another answer) htop is one of the tools to see process info. If the 'S' column (for Status) is showing a 'D', it means that the process is blocked, usually waiting for I/O operations to finish. Increase bandwith for network or storage (eg RAID or faster HDD/SSD/NVMe) to deal with that bottleneck. iotop is another useful ...


1

No there is no such thing as opportunistic swapping in Linux. I've spent some time looking at the issue and all the sources (textbooks, emails on kernel developers' mail lists, Linux source code and commit comments, and some Twitter exchanges with Mel Gorman) are telling me the same thing: Linux only reclaims memory in response to some form of memory ...


1

Believe you could use /proc/vmstat output, say with cat /proc/vmstat | grep pswp command. This will show you swap in and swap out counters. Or: only si: vmstat 1 1 | awk 'NR == 1 {next} NR == 2 {for (i = 1; i <= NF; i++) fields[$i] = i; next} {split($0, data); item = data[fields["si"]]; print item; totals[fields["si"]] += item} NR >= 6 + 2 {exit}'...


1

I was pondering over a similar question -- you saw my thread about kswapd and zone watermarks -- and the answer in my case (and probably in yours as well) is memory fragmentation. When memory is fragmented enough, higher order allocation will fail, and this (depending on a number of additional factors) will either lead to direct reclaim, or will wake ...


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