Hot answers tagged

16

Often a mv is closer to a rename than a copy. In a classic unix type file system, the inodes that contain the file data won't be replicated if the source and the destination are on the same mount point. Instead a new filename is created that points to the same inodes, and the old filename is unlinked. If the mv is to another mount point, then it will be ...


11

This statement is odd: split("0,2,4,5,7,9,11,12",a,","); It repetitively splits a constant string to create an array a. If you move that into a BEGIN section, the program should work the same — without allocating a new copy of the a array for each input-record. Addressing comments: the for-loop and expression do not allocate memory in a simple ...


8

In your second reference, where it says The memory allocator gets a big chunk of memory (say, 4 pages, or 4 * 4 KiB) and divides this into much smaller chunks "the memory allocator" is not the kernel but the libc routines like malloc. The kernel allocates memory to the process in page-sized chunks. malloc keeps track of used and unused portions of ...


5

You can press the following keys: e -- Change the scaling factor on the summary display Shift+e -- Change the scaling factor on the task Shift+w -- Save current settings


5

This is not a loop, but recursion and the memory increases linear over the time, which is what you don't want. If you want a loop with constant memory usage, you can do it this way: #!/bin/sh while 1; do mysql -h "localhost" -u "root" "-p********" "database" < "update.sql" sleep 5 done


5

How can I see the raw memory data used by an application... Once you have obtained the process' PID (using ps(1) or pidof(8) for instance), you may access the data in its virtual address space using /proc/PID/maps and /proc/PID/mem. Gilles wrote a very detailled answer about that here. ... and all the files its accessing in my filesystem, network data ...


5

If the system supports process accounting, and accounting is enabled, then there may be records available in the process accounting file, e.g. on RedHat Linux: $ grep -q BSD_PROCESS_ACCT=y /boot/config-* && echo hooray hooray $ sudo touch /var/log/pacct $ sudo accton /var/log/pacct $ ... $ sudo accton # turn it off Parsing the acct(5) file is ...


5

The short story: If your mobo posts, and your system boots, and free/top show your ram as 16 gB, then it works. Even mobo makers can under-report capacity of system boards, so the real test is if ram is installed correctly, matched correctly, runs, ie, boots, and runs with stability, ie, doesn't crash, then it works. You can also test by trying to use all ...


5

niceload --noswap yourprg is made for exactly that situation: It looks at swapping activity: If swapping out: Let process run If swapping in: Let process run If swapping in and out: Suspend process until swapping stops and resume the process when swapping has stopped It does not suspend the process before the swapping starts, but lets swapping run for 1 ...


5

MemAvailable is included in /proc/meminfo since version 3.14 of the kernel; it was added by commit 34e431b0a. That's the determining factor in the output variations you show. The commit message indicates how to estimate available memory without MemAvailable: Currently, the amount of memory that is available for a new workload, without pushing the system ...


4

From what you have posted it doesn't seems like you under stand how memory works in Linux. I recommend reading http://www.linuxnix.com/find-ram-size-in-linuxunix/ http://www.itworld.com/article/2722141/it-management/making-sense-of-memory-usage-on-linux.html http://www.linuxatemyram.com/ The jist of those sites is that you have more "free" ram then ...


4

Here's a perl equivalent that doesn't leak: perl -lne 'BEGIN { @a=(0,2,4,5,7,9,11,12);} for ($i = 0; $i < 1; $i+= 0.0001) { printf("%08X\n", 100*sin(1382*exp($a[$F[0] % 8]/12)*log(2))*$i) }' It's almost identical. $1 gets replaced by $F[0] and i is replaced with $i. The hash a is replaced with an actual array, @a. You would be wise to generate ...


4

free is provided by procps-ng; Debian 8 has version 3.3.9, which uses the old style with a separate line for buffers/cache, while Gentoo and presumably RHEL 7.x have version 3.3.10 or later which uses the new style. You can see the reasoning behind the change in the corresponding commit message. If you really want the old-style output you can run an older ...


4

Processes are managed by the kernel. The kernel doesn't care how the programmer allocates variables. All it knows is that certain blocks of memory belong to the process. The C runtime matches C memory management features to kernel features: automatic variables go into a memory block called “stack” and dynamic storage (malloc and friends) go into a memory ...


3

You can get this information through the virtual /proc file-system (under Linux only). Try to run this command when the process is running (replace the <pid> by the PID of the observed process): grep 'VmSize' /proc/<pid>/status Beware, you have to have read access to the process to get these information (you cannot access it if you do not ...


3

Partial answer: You can see the files it accesses in real-time by using strace something.sh Specifically, it shows you every system call made by the process.


3

I'm not sure why you want to drop the caches every hour - that is going to kill performance. There are a few problems with what you've done: You need to edit the crontab of root, as you cannot write to /proc/sys/vm/drop_caches as a non-root user. Your crontab entry is not correct. It should be: 2 * * * * /usr/bin/free && sync && echo 3 &...


3

As you fill the memory with apps various block/filesystem caches are getting pushed out of the same memory. These caches are crucial for fast look up of files and other stuff. When there is no space for caches the kernel will try to look up all the information directly from the filesystem which is utterly slow and hence will cause high IO (more like a ...


3

Indeed you need to use /proc/; so read carefully proc(5). For process 1234 you want to read /proc/1234/maps (or /proc/1234/smaps) to get the address space, and to read /proc/1234/status & /proc/1234/statm For your own process (programmatically) use /proc/self/maps, /proc/self/status, /proc/self/statm Notice that memory usage is a very ambiguous term ...


3

You could - probably. From the man page: While this is a good point in terms of report speed and safeness, this also makes the presented information possibly unreliable. You'll also still need to work out exactly what type and what speed that you'll need for your laptop. Why not use http://www.crucial.com or a similar site and enter the details ...


3

I suggest you look into the LDD3 book, it is free. It does explain ioremap in chapter 9, page 249. Also look into APIU 3rd edition, chapter 14.8, page 525. Let me summarize, best to my abilities: ioremap is a kernel function that allows to access hardware through a mechanism called I/O mapped memory. There are certain addresses in memory that are ...


3

OS Memory v. Ubuntu Memory v. Kernel Memory You have asked to know how much the "Linux OS" is using (and not how much memory is being used by "applications"). "Linux" is just a kernel (albeit not a monolithic one; kernel modules contribute to the effective footprint). Many things that end users see as "the OS" are not part of the kernel, but part of the ...


3

It is because htop is counting buffers and cached memory as free memory, because it can actually can be seen this way. There is no "cost" in having some cached data in memory, so the kernel keep stuff there just in case it needs afterwards. For instance, suppose you have watched a video of about 500mb, after you close the video, the kernel may decide to ...


3

Linux does not "automatically create" a region for both, heap and stack segments. In programming languages there is always an entry point, where control is transferred from the operating system to the program. In C, this is the main() function. Each process in Linux has a memory mapping of 4GB in 32-Bit and 8TB in 64-Bit environments. This is the maximum ...


3

No. Even if there were the possibility of dumping the memory of the application to read the content of the unwritten logs, once you restarted the application the old process ended, and its memory is gone.


3

Not the program as it is executed in memory but the page cache keeps all the files (executable, libraries, and configuration files). Thus the time for the disk access may be saved on the second execution. But the dynamic linking has to be done again.


3

Swap space is located on hard drives, which have a slower access time than RAM. Also the CPU cannot access/address hard drives directly because there is no direct physical data connection between the CPU and the HDD.


3

I don't think there is a way to limit swap space, unless you modify the program to only request non-swappable memory, which even if possible would probably be impractical. However what you can and should do is limit the total amount of memory available to the process. You can use cgroups (the new-ish general way), ulimit (setrlimit, the traditional way), or ...


3

MM seems to be quite arcane, so it is indeed annoying to track down. Linux literature makes heavy mention of LRU in the context of MM (memory management). I haven't noticed any of the other terms being mentioned. If you're not familiar with how basic LRU is implemented in practice for virtual memory, I came across an interesting introduction (first four ...


3

You can use ps together with awk to find the physical memory usage by a user: ps -U root --no-headers -o rss | awk '{ sum+=$1} END {print int(sum/1024) "MB"}' Here it prints memory used by root to the output.



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