[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ast-developers
Subject:    [ast-developers] ksh93 on Solaris not releasing memory back to
From:       roland.mainz () nrubsig ! org (Roland Mainz)
Date:       2007-06-10 23:18:58
Message-ID: 466CBEF5.D6AAAED9 () nrubsig ! org
[Download RAW message or body]

Roland Mainz wrote:
> While running some tests I've observed that ksh93 currently doesn't
> release the memory allocated to the system when it's no longer needed
> (e.g. a function local array with 120MB of data gets unset when the
> function exits but the shell process continues to squat the memory). A
> quick look shows that libast currently uses |sbrk()| for allocations
> which is slightly sub-optimal for long-running system scripts (Sun's bug
> database has some interesting bugs about ksh88 not releasing memory
> which turns out to be the same problem (and not a leak as some reports
> claim)).
> 
> Is there any way to switch the default libast memory allocator to use
> |mmap(..., MAP_ANON, ...)| instead of |sbrk()| or make this configurable
> via a build or runtime environment variable ?

Attached is a small patch ("ksh93_disable_use_of_sbrk_001.diff.txt")
which adds an compile-time option ("-D_ast_disable_sbrk=1") to disable
the use of |sbrk()|&co. on demand...

... while thinking about it... would it be usefull to modify the iffe
probe generation a little bit that all probed values can ve overridden
manually ?
For example via setting
"-D_ast_override_mem_sbrk=0" the "mem_sbrk"-probe in
src/lib/libast/features/vmalloc could be overridden with a hardcoded
value and the probe itself would then print:
-- snip --
iffe: test: brk()/sbrk() work as expected ... no [manual override]
-- snip --
(AFAIK that may be a cleaner approach compared to "hack each probe") ...

----

Bye,
Roland

-- 
  __ .  . __
 (o.\ \/ /.o) roland.mainz@nrubsig.org
  \__\/\/__/  MPEG specialist, C&&JAVA&&Sun&&Unix programmer
  /O /==\ O\  TEL +49 641 7950090
 (;O/ \/ \O;)
-------------- next part --------------
--- src/lib/libast/features/vmalloc	2007-06-11 04:33:38.000000000 +0200
+++ src/lib/libast/features/vmalloc	2007-06-11 04:33:47.000000000 +0200
@@ -17,6 +17,9 @@
 typ	ssize_t
 
 tst	mem_sbrk note{ brk()/sbrk() work as expected }end execute{
+	#if _ast_disable_sbrk
+	int main() { return 1; }
+	#else
 	#include        <sys/types.h>
 	#include        <unistd.h>
 	#undef	uchar
@@ -42,6 +45,7 @@
 
 		return 0;
 	}
+	#fi
 }end
 
 tst	map_malloc note{ map malloc to _ast_malloc }end noexecute{

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic