Sponsored Content
Top Forums Programming Size of memory used by a program Post 302931311 by shamrock on Monday 12th of January 2015 12:27:55 PM
Old 01-12-2015
Quote:
Originally Posted by Don Cragun
Not quite. It shows the size of the static data segment loaded when the process starts; it doesn't show the size of data allocated while the process is running (as in the 3 calls to malloc() in the given code snippet).
It is correct that the size command wont tell us anything about the runtime size of the heap allocated...but even accounting for malloc wont tell us how much data is allocated on the stack where function arguments and local variables are pushed...
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

Program/ Memory Problems

I need some advise. I have an application server running several applications. When I try and start a particular application when the others are running I receive the following. This is appearing in the core file that is created. ... (1 Reply)
Discussion started by: dbrundrett
1 Replies

2. UNIX for Advanced & Expert Users

memory size under AIX

Hi, how to know size of physical memory under AIX ? Many thanks. PS : man -k memory man : 0703-310 Fichier man introuvable. uname -a AIX server1 1 5 005202DF4C00 (3 Replies)
Discussion started by: big123456
3 Replies

3. Programming

Measuring memory used by a program?

I have a Java program. I want to measure the total memory used by the program, especially the peak memory. Is there a way to do it? I have tried utilities like time (which returns 0) and top (which is not very useful) as the program does not run for long. Can anyone suggest a way to do this?... (5 Replies)
Discussion started by: spathical
5 Replies

4. Solaris

How to know the size of the program currently executing in memory

hey everybody, i am currently working on solaris 10 os on a m5000 server. my problem is when i want the exact size of a program in execution, i am unable to do it. earlier i thought the RSS field of prstat but because of its large size it cant be the size. pmap -x shows some output but it includes... (2 Replies)
Discussion started by: aryansheikh
2 Replies

5. UNIX for Advanced & Expert Users

Out of Memory error when free memory size is large

I was running a program and it stopped and showed "Out of Memory!". at that time, the RAM used by this process is around 4G and the free memory size of the machine is around 30G. Does anybody know what maybe the reason? this program is written with Perl. the OS of the machine is Solaris U8. And I... (1 Reply)
Discussion started by: lilili07
1 Replies

6. Solaris

Memory or CPU size

Is there a command or file I can look at that tells me how much real memory a machine has? A little background. In my shop we run a bunch of java programs, sometimes some of these jobs have config definitions that call for 2G. I would like to know how many I can run before I exhaust rescources. Any... (12 Replies)
Discussion started by: Harleyrci
12 Replies

7. AIX

Memory limit for C program

Greetings - I'm porting a C application to an AIX (6.1) system, and have bumped into the limits AIX imposes on memory allocation, namely the default limit of 256MB for a process. I'm aware of the compilation flag that allows an application to gain access to up to 8 memory segments (each 256MB,... (4 Replies)
Discussion started by: traviswheeler
4 Replies

8. Programming

Shared memory between two c program

i have to shared a variable between two different c programs with shared memory and i do these: int main() { int a=5,b=7; int buffer; int *point; int shmid; shmid=shmget(IPC_PRIVATE , sizeof(buffer),0666); point=(int *)shmat(shmid,NULL,0); point=a; ... (21 Replies)
Discussion started by: tafazzi87
21 Replies

9. Programming

Help regarding memory leak in this C program

I have written this code in C which reads a very large collection of text files and does some processing. The problem with this code is that there are memory leaks which I am not able to figure out as to where the problem is. When I run this code, and see the memory usage using top command, then I... (7 Replies)
Discussion started by: shoaibjameel123
7 Replies

10. UNIX for Dummies Questions & Answers

Getting file size from memory

i want to avoid writing to a file on the disk. i'd like to do this in memory. i have a situation where i'm running cat file.txt | head -l 2024 > /tmp/data.txt now, i check the size of the data.txt by doing a "du -sh /tmp/data.txt how can i get the size of "head -l 2024" WITHOUT having to... (2 Replies)
Discussion started by: SkySmart
2 Replies
mtmalloc(3MALLOC)														 mtmalloc(3MALLOC)

NAME
mtmalloc, mallocctl - MT hot memory allocator SYNOPSIS
#include <mtmalloc.h> cc -o a.out -lthread -lmtmalloc void *malloc(size_t size); void free(void *ptr); void *memalign(size_t alignment, size_t size); void *realloc(void *ptr, size_t size); void *valloc(size_t size); void mallocctl(int cmd, long value); The malloc() and free() functions provide a simple general-purpose memory allocation package that is suitable for use in high performance multithreaded applications. The suggested use of this library is in multithreaded applications; it can be used for single threaded appli- cations, but there is no advantage in doing so. This library cannot be dynamically loaded with dlopen(3C) during runtime because there must be only one manager of the process heap. The malloc() function returns a pointer to a block of at least size bytes suitably aligned for any use. The argument to free() is a pointer to a block previously allocated by malloc() or realloc(). After free() is performed this space is available for further allocation. If ptr is a null pointer, no action occurs. The free() function does not set errno. Undefined results will occur if the space assigned by malloc() is overrun or if a random number is handed to free(). A freed pointer that is passed to free() will send a SIGABRT signal to the calling process. This behavior is controlled by mallocctl(). The memalign() function allocates size bytes on a specified alignment boundary and returns a pointer to the allocated block. The value of the returned address is guaranteed to be an even multiple of alignment. Note that the value of alignment must be a power of two, and must be greater than or equal to the size of a word. The realloc() function changes the size of the block pointed to by ptr to size bytes and returns a pointer to the (possibly moved) block. The contents will be unchanged up to the lesser of the new and old sizes. If the new size of the block requires movement of the block, the space for the previous instantiation of the block is freed. If the new size is larger, the contents of the newly allocated portion of the block are unspecified. If ptr is NULL, realloc() behaves like malloc() for the specified size. If size is 0 and ptr is not a null pointer, the space pointed to is freed. The valloc() function has the same effect as malloc(), except that the allocated memory will be aligned to a multiple of the value returned by sysconf(_SC_PAGESIZE). After possible pointer coercion, each allocation routine returns a pointer to a space that is suitably aligned for storage of any type of object. The malloc(), realloc(), memalign(), and valloc() functions will fail if there is not enough available memory. The mallocctl() function controls the behavior of the malloc library. The options fall into two general classes, debugging options and per- formance options. MTDOUBLEFREE Allows double free of a pointer. Setting value to 1 means yes and 0 means no. The default behavior of double free results in a core dump. MTDEBUGPATTERN Writes misaligned data into the buffer after free(). When the buffer is reallocated, the contents are verified to ensure that there was no access to the buffer after the free. If the buffer has been dirtied, a SIGABRT signal is delivered to the process. Setting value to 1 means yes and 0 means no. The default behavior is to not write mis- aligned data. The pattern used is 0xdeadbeef. Use of this option results in a performance penalty. MTINITBUFFER Writes misaligned data into the newly allocated buffer. This option is useful for detecting some accesses before initialization. Setting value to 1 means yes and 0 means no. The default behavior is to not write misaligned data to the newly allocated buffer. The pattern used is 0xbaddcafe. Use of this option results in a performance penalty. MTCHUNKSIZE This option changes the size of allocated memory when a pool has exhausted all available memory in the buffer. Increasing this value allocates more memory for the application. A substantial performance gain can occur because the library makes fewer calls to the OS for more memory. Acceptable number values are between 9 and 256. The default value is 9. This value is multiplied by 8192. If there is no available memory, malloc(), realloc(), memalign(), and valloc() return a null pointer. When realloc() is called with size > 0 and returns NULL, the block pointed to by ptr is left intact. If size, nelem, or elsize is 0, either a null pointer or a unique pointer that can be passed to free() is returned. If malloc() or realloc() returns unsuccessfully, errno will be set to indicate the error. The malloc() and realloc() functions will fail if: ENOMEM The physical limits of the system are exceeded by size bytes of memory which cannot be allocated. EAGAIN There is not enough memory available to allocate size bytes of memory; but the application could try again later. Comparative features of the various allocation libraries can be found in the umem_alloc(3MALLOC) manual page. See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |MT-Level |Safe | +-----------------------------+-----------------------------+ brk(2), getrlimit(2), bsdmalloc(3MALLOC), dlopen(3C), malloc(3C), malloc(3MALLOC), mapmalloc(3MALLOC), signal.h(3HEAD), umem_alloc(3MAL- LOC), watchmalloc(3MALLOC), attributes(5) WARNINGS
Undefined results will occur if the size requested for a block of memory exceeds the maximum size of a process's heap. This information may be obtained using getrlimit(). 21 Mar 2005 mtmalloc(3MALLOC)
All times are GMT -4. The time now is 02:39 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy