Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - shrinking process heap: (3 Items)
   
shrinking process heap  
Process A does a large malloc, resulting in a mmap MAP_PRIVATE | MAP_ANON to grow the heap, then immediately calls 
free() and goes to sleep.

Process B attempts a malloc but there isn't enough free memory to satisfy the request so it returns 0. Meanwhile most of
 process A's heap is unused.

Is there a mechanism to trigger heap shrink on Process A so that Process B's malloc does not fail?

Thanks,
asherk
Re: shrinking process heap  
Whether process 'A's  memory gets released from its heap to the system
is a function of its current heap state, and the controlling parameters
of the heap of process A. There is really no way of making process A
release its cached heap memory from an external process.

If you really wanted this, you would need to have process A, excplitly
sets its caching levels, or respond to such an external request, to
release its heap by calling mallopt with appropriate options

shiv
Tue May 10 15:14:57 EDT 2011
 --> According to Andrew Sherk <--
	Process A does a large malloc, resulting in a mmap MAP_PRIVATE |
	MAP_ANON to grow the heap, then immediately calls free() and goes to
	sleep.
	
	Process B attempts a malloc but there isn't enough free memory to
	satisfy the request so it returns 0. Meanwhile most of process A's heap
	is unused.
	
	Is there a mechanism to trigger heap shrink on Process A so that Process
	B's malloc does not fail?
	
	Thanks,
	asherk
	
	
	
	
	_______________________________________________
	
	OSTech
	http://community.qnx.com/sf/go/post85561
	

-- 
****
Shiv Nagarajan,
Kernel Developer, QNX Software Systems,
Ottawa, Canada
****
RE: shrinking process heap  
Thanks, Shiv.
I gave mallopt(MALLOC_ARENA_CACHE_FREE_NOW, 1) a try and I see the
resulting munmap, shrinking the heap.

asherk

-----Original Message-----
From: Shiv Nagarajan [mailto:community-noreply@qnx.com] 
Sent: Tuesday, May 10, 2011 3:16 PM
To: ostech-core_os
Subject: Re: shrinking process heap

Whether process 'A's  memory gets released from its heap to the system
is a function of its current heap state, and the controlling parameters
of the heap of process A. There is really no way of making process A
release its cached heap memory from an external process.

If you really wanted this, you would need to have process A, excplitly
sets its caching levels, or respond to such an external request, to
release its heap by calling mallopt with appropriate options

shiv
Tue May 10 15:14:57 EDT 2011
 --> According to Andrew Sherk <--
	Process A does a large malloc, resulting in a mmap MAP_PRIVATE |
	MAP_ANON to grow the heap, then immediately calls free() and
goes to
	sleep.
	
	Process B attempts a malloc but there isn't enough free memory
to
	satisfy the request so it returns 0. Meanwhile most of process
A's heap
	is unused.
	
	Is there a mechanism to trigger heap shrink on Process A so that
Process
	B's malloc does not fail?
	
	Thanks,
	asherk
	
	
	
	
	_______________________________________________
	
	OSTech
	http://community.qnx.com/sf/go/post85561
	

-- 
****
Shiv Nagarajan,
Kernel Developer, QNX Software Systems,
Ottawa, Canada
****



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post85563