08-06-2008
That is because the kernel allocated 370MB of memory to the process - once a process gets memory it keeps that memory allocated until the process ends. This is because calls to brk() to allocate memory are very expensive, and brk() would be called to 'give back' the memory as well as to allocate it.
You can try man brk to see if you want to try memory management yourself. However what you see is expected behavior.
10 More Discussions You Might Find Interesting
1. Programming
Hi
i was trying to compile one of my project source file which is neary 2MB large.
i couldnt compile it, instead getting an error like "insufficient virtual memory"
how come i get away with this problem ,please suggest.
thanks (1 Reply)
Discussion started by: Raom
1 Replies
2. Programming
hi
i have a code:
I found that after exiting from child thread memory isn't freed. I commented everything which is "some actions" here, so thread's function contains only two lines. But it doesn't help.
What do I do wrong?
Thanks a lot (3 Replies)
Discussion started by: sery0ga
3 Replies
3. Programming
Hi all!
I am implementing an http server in c++ using the posix thread, but i am having a memory leak and i cannot find the reason.
I have already commented out the section that initializes the threads and i found out, the problem is when i initialize/run the threads.
In the threads i have... (1 Reply)
Discussion started by: laurovalente
1 Replies
4. UNIX for Advanced & Expert Users
hi
I had to create a shared memory segment which allows the creation of 8 child processes each with 1024 bytes and contains a common buffer area of 2096bytes.
i was able to create the shared memory with shm_open() followed by ftruncate() and mmap() system calls.
but for the shared buffer, i... (3 Replies)
Discussion started by: pretty
3 Replies
5. AIX
Hi,
Would any one be so kind to explain me :
are ulimits defined for each user seperately ? When ?
Specialy what is the impact of :
max locked memory
and
virtual memory
on performance of applications for a user.
Many thanks.
PS :
this is what I can see in MAN :
ulimit ]
... (5 Replies)
Discussion started by: big123456
5 Replies
6. UNIX for Dummies Questions & Answers
Hi All,
Does anyone know what the best commands in the UNIX command line are for obtaining this info:
current CPU usage
memory usage
virtual memory usage
preferably with date and time parameters too?
thanks
ocelot (4 Replies)
Discussion started by: ocelot
4 Replies
7. UNIX for Advanced & Expert Users
i am creating threads in my program using the POSIX interface.
when the thread starts executing i run out of memory and get a core dump.
i have tried to increase the threads stack size using pthread_attr_setstacksize, but of no use since i guess the dynamic memory is allocated on the heap and... (1 Reply)
Discussion started by: aniketkadu2002
1 Replies
8. Programming
I have this code...
#include <stdio.h>
#include <iostream>
#include <pthread.h>
static void* cliente(void *datos);
int main()
{
pthread_attr_t tattr;
int ret;
size_t size = PTHREAD_STACK_MIN + 0x0100;
ret = pthread_attr_init(&tattr);
ret =... (8 Replies)
Discussion started by: JEscola
8 Replies
9. Programming
Hi,
I wanted to know whether the POSIX message queues are statically allocated memory by the kernel based on the parameters specified in the open or as and when we send messages, memory are allocated?
Does the kernel reserve the specified memory for the message queue irrespective of whether... (1 Reply)
Discussion started by: sumtata
1 Replies
10. Solaris
Hi
I have a problem with Virtual Memory on one local zone (myzone1):
//from local zone (myzone1)
swap -s
total: 22888544k bytes allocated + 0k reserved = 22888544k used, 3325856k available
swap -l
swapfile dev swaplo blocks free
/dev/swap ... (0 Replies)
Discussion started by: primo102
0 Replies
BRK(2) Linux Programmer's Manual BRK(2)
NAME
brk, sbrk - change data segment size
SYNOPSIS
#include <unistd.h>
int brk(void *addr);
void *sbrk(intptr_t increment);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
brk(), sbrk():
Since glibc 2.12:
_BSD_SOURCE || _SVID_SOURCE ||
(_XOPEN_SOURCE >= 500 ||
_XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED) &&
!(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
Before glibc 2.12:
_BSD_SOURCE || _SVID_SOURCE || _XOPEN_SOURCE >= 500 || _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED
DESCRIPTION
brk() and sbrk() change the location of the program break, which defines the end of the process's data segment (i.e., the program break is
the first location after the end of the uninitialized data segment). Increasing the program break has the effect of allocating memory to
the process; decreasing the break deallocates memory.
brk() sets the end of the data segment to the value specified by addr, when that value is reasonable, the system has enough memory, and the
process does not exceed its maximum data size (see setrlimit(2)).
sbrk() increments the program's data space by increment bytes. Calling sbrk() with an increment of 0 can be used to find the current loca-
tion of the program break.
RETURN VALUE
On success, brk() returns zero. On error, -1 is returned, and errno is set to ENOMEM. (But see Linux Notes below.)
On success, sbrk() returns the previous program break. (If the break was increased, then this value is a pointer to the start of the newly
allocated memory). On error, (void *) -1 is returned, and errno is set to ENOMEM.
CONFORMING TO
4.3BSD; SUSv1, marked LEGACY in SUSv2, removed in POSIX.1-2001.
NOTES
Avoid using brk() and sbrk(): the malloc(3) memory allocation package is the portable and comfortable way of allocating memory.
Various systems use various types for the argument of sbrk(). Common are int, ssize_t, ptrdiff_t, intptr_t.
Linux Notes
The return value described above for brk() is the behavior provided by the glibc wrapper function for the Linux brk() system call. (On
most other implementations, the return value from brk() is the same; this return value was also specified in SUSv2.) However, the actual
Linux system call returns the new program break on success. On failure, the system call returns the current break. The glibc wrapper
function does some work (i.e., checks whether the new break is less than addr) to provide the 0 and -1 return values described above.
On Linux, sbrk() is implemented as a library function that uses the brk() system call, and does some internal bookkeeping so that it can
return the old break value.
SEE ALSO
execve(2), getrlimit(2), end(3), malloc(3)
COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
Linux 2010-09-20 BRK(2)