Sponsored Content
Top Forums UNIX for Beginners Questions & Answers Interpreting Linux's free command output Post 303010976 by drysdalk on Thursday 11th of January 2018 08:56:15 AM
Old 01-11-2018
Hello,

I would imagine that under normal circumstances the kernel would choose to allocate memory from the free pool first, before flushing out buffers, cache or anything else. It all depends precisely on what kind of memory the process is wanting to allocate and for what purpose, but in general memory which is totally unused would be used up first, and then when free memory fell below a certain threshold the system would most likely become more aggressive about freeing up cached memory for actual use by running processes.

In either case, so long as memory is available, a process will be able to use it, so where exactly it comes from is normally not something you need to worry about or consider. If a process needs memory and it's available by one means or another, the system will allocate it.
This User Gave Thanks to drysdalk For This Post:
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

How to Use the Free Command in Linux

I know that free command displays memory usages however I like to know how the option and the results when I use this command.. PLease respond ASAP thanx... I am a newbie.. :D (1 Reply)
Discussion started by: LiTo
1 Replies

2. UNIX for Dummies Questions & Answers

Interpreting java output stream as system commands in Solaris

Hi there again, Running Solaris 10 with built-in Java. Seems to compile and run fine. Problem is: Say I want to see contents of current directory. In a shell, I'd just write "ls" and it outputs the content. When I write a Java file, I have the following line: System.out.println("ls"); ... (1 Reply)
Discussion started by: EugeneG
1 Replies

3. Shell Programming and Scripting

Interpreting Logicals/Environment Variables using the read command

Hi All I have something that from the outset seems really trivial but in practice is not quite working. I have the following code sample in my shell script which illustrates the problem echo "enter home directory" read home mkdir $home/newdir The user then enters a logical $HOME... (3 Replies)
Discussion started by: kingpin2502
3 Replies

4. UNIX for Dummies Questions & Answers

interpreting netstat output

hi all, when I run- wcars1j5#netstat -an | grep 8090 127.0.0.1.8090 *.* 0 0 49152 0 LISTEN wcars1j5# 1. does this mean that no one is connected to this port? Regards, akash (1 Reply)
Discussion started by: akash_mahakode
1 Replies

5. UNIX for Dummies Questions & Answers

Interpreting prtdiag output - 2 or 4 CPUs?

I am having trouble figuring this one out.....Is this a 2CPU or a 4CPU v490 with 16GB? I think it is a 2CPU system, looking for confirmation. $ prtdiag System Configuration: Sun Microsystems sun4u Sun Fire V490 System clock frequency: 150 MHz Memory size: 16384 Megabytes ... (1 Reply)
Discussion started by: config_boy
1 Replies

6. UNIX for Advanced & Expert Users

Output of Free command in unix?

Hello, I need some help to interpret the below output... What is -/+ buffers/cache? My understanding is, total RAM is 3986152 Bytes, used RAM is 3950904 bytes. What is buffers and cached?? Can any one please interpret this output? It would be great help if some one can help me on this? ... (2 Replies)
Discussion started by: govindts
2 Replies

7. Red Hat

Understand output of "free" command

Hi Friends, I am really confused with the output of "free" command on redhat linux. I can see caching and buffer output on two different areas on the output. Please let me know whats the difference of these two different outputs. Here I am pasting the command output of my server. # free... (3 Replies)
Discussion started by: arumon
3 Replies

8. Solaris

Interpreting xntpdc output.

Hi. I wonder what the equal sign in front of the answer means. I have read man pages and googled but found no answer. xntpdc -p =15.5.64.3 15.5.2.51 3 512 377 0.02060 0.057426 0.04965Thanks. Jan (1 Reply)
Discussion started by: vettec3
1 Replies

9. Shell Programming and Scripting

Linux command to output from a string

Hi All, I have a file with name Is there a LINUX command that will help me to output the word after the 9th Underscore(_). ie the output should be DLY in this case. Can anybody pls help me. Thanks much in advance, Freddie (4 Replies)
Discussion started by: dsfreddie
4 Replies

10. Red Hat

Concept of free –m command in Linux

I wanted to know the concept of free -m command as there are different rows of Mem, -/+ buffers/cache & Swap in the output. As an example, it is showing 195 as free Mem in my server but 13850 in the free section of the -/+ buffers/cache row. The output needs in depth knowledge of the different... (7 Replies)
Discussion started by: RHCE
7 Replies
MALLOC(9r)																MALLOC(9r)

NAME
MALLOC - General: Allocates a variable-size section of kernel virtual memory SYNOPSIS
#include <sys/malloc.h> MALLOC( addr, cast, u_long size, int type, int flags ); ARGUMENTS
Specifies the memory pointer that points to the allocated memory. You specify the addr argument's data type in the cast argument. Speci- fies the data type of the addr argument and the type of the memory pointer returned by MALLOC. Specifies the size in bytes of the memory to allocate. Typically, you pass the size as a constant to speed up the memory allocation. Specifies the purpose for which the memory is being allocated. The memory types are defined in the file <malloc.h>. Typically, kernel modules use the constant M_DEVBUF to indicate that kernel module memory is being allocated (or freed). Specifies one of the following flag constants defined in /usr/sys/include/sys/mal- loc.h: Allocates memory from the virtual memory subsystem if there is not enough memory in the preallocated pool. This constant signifies that MALLOC can block. Does not allocate memory from the virtual memory subsystem if there is not enough memory in the preallocated pool. This constant signifies that MALLOC cannot block. Allocates zero-filled memory. You pass this bit value by ORing it to M_WAITOK or M_NOWAIT. DESCRIPTION
The MALLOC routine (macro) allocates at least size bytes from the kernel memory and returns the address of the allocated memory. A kernel module can allocate the memory in interrupt and process contexts. The MALLOC routine (macro) maintains a pool of preallocated memory for quick allocation. If there is not enough memory in the pool, MALLOC allocates memory from the virtual memory subsystem by calling kmem_alloc, which can potentially block (sleep). A kernel thread that allo- cates and frees memory to and from the preallocated pool. The MALLOC routine (macro) is actually a wrapper that calls malloc. A kernel module should not directly call the MALLOC routine. The type argument allows the memory allocator to keep track of memory usage by a subsystem. If the allocation size is greater than 16K, you must pass M_WAITOK to the flags argument. You cannot allocate more than 16K bytes of memory in interrupt context. NOTES
A memory corruption can occur if a device driver continues to use the memory after freeing it. The operating system provides a built-in mechanism to debug such erroneous use of memory. You can enable this debugging feature at boot time by providing the following boot parame- ter: kmem_debug=1. When you enable this debugging feature, the FREE routine stores the following in the last word of freed memory: The pro- gram counter (pc) of the module that last freed the memory The checksum of the memory content The MALLOC routine checks the checksum of the memory content before reallocating this corrupted memory. If the checksum of the memory con- tent does not match the corrupted memory, MALLOC stores the debug information and then causes the kernel to panic. The MALLOC routine stores the address and size of the corrupted memory and the pc of the routine that last freed it in a kmem_corrupt_data structure. You should consider the following when using this debugging feature: This debugging feature does not detect cases where the corruption occurs after MALLOC reallocates the freed memory to some other module. There is a small chance that the pc of the routine that freed the memory (stored in the last word of freed memory) may itself become corrupted. CAUTIONS
A device driver must not call MALLOC in interrupt context with the flags argument set to M_WAITOK. If flags is set to M_WAITOK, MALLOC checks if the kernel thread is in interrupt context. If so, MALLOC returns a null pointer and displays a message on the console terminal. The M_WAITOK flag implies that it is valid to allocate memory from the virtual memory subsystem if there is not enough memory in the preal- located pool. To be able to allocate memory from the virtual memory subsystem (which can page fault), the device driver must be in process context. RETURN VALUES
Upon successful completion, MALLOC returns the address of the allocated memory. The return type associated with this address is the same as that specified for the addr argument. If the memory allocation request cannot be fulfilled, MALLOC returns a null pointer in the addr argument. SEE ALSO
Routines: FREE(9r) MALLOC(9r)
All times are GMT -4. The time now is 06:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy