[Mono-dev] Re: [Mono-devel-list] Limiting Memory Allocation
jimpurbrick at yahoo.co.uk
Wed Jan 18 15:18:44 EST 2006
At the moment no memory is allocated by the script,
it's all allocated by calls in to unmanaged library
functions or by Deserialization, so I could get the
library calls to track the memory they allocate for
scripts and then store that in the script, so when
it's deserialized I still know how much memory the
script is using.
That works in the short term, but isn't a general
solution for when we allow other languages which can
dynamically allocate memory outside library calls and
open up bits of the .NET framework which may allocate
memory themselves. I don't want to have to transform
the bytecode of all the .NET libraries to inject code
around every newobj or newarr instruction. Also, is
there enough information present at bytecode
transormation time to work out how much memory is
The profiler approach is nice if only I could avoid
including the extra Deserialization info and measuring
the size of binary serializations seems simple and
If anyone else has any ideas how best to do this
please let me know.
--- Zoltan Varga <vargaz at gmail.com> wrote:
> If you are talking about the memory allocated by
> the script itself,
> I think the best solution would be to explicitly
> generate code to
> track it, i.e. for each newobj
> or newarr IL opcode you emit, emit some statements
> to increase a counter or
> On 1/18/06, Jim Purbrick <jimpurbrick at yahoo.co.uk>
> > Hi Ben/Everyone,
> > --- Ben Maurer <bmaurer at ximian.com> wrote:
> > > Look at heap-prof. My profiler traps memory
> freed by
> > > the gc.
> > This is currently what I'm using to measure the
> > used by different scripts. I basically wrap calls
> > the scripts in calls to the profiler which turn on
> > off memory allocation monitoring.
> > There are 2 problems with this approach:
> > 1) When I deserialize a script the single call to
> > IFormatter.Deserialise allocates a lot of memory
> > than the memory used by the script and a lot of
> > objects don't seem to be GCed, so a lot of objects
> > allocated by the script end up being counted
> > the script's memory usage.
> > 2) I end up using a lot of memory to keep
> > to every object allocated by the script so that
> when a
> > GC occurs I can iterate through the list and
> > memory to the script for every object in the list
> > which has been collected.
> > Can anyone think of ways round these problems or
> > better ways to keep track of the memory allocated
> > scripts? Given that I use serialization to move
> > scripts between appdomains and processes I wonder
> > whether just measuring the size of a binary
> > serialization of the script might be a close
> > approximation of its memory usage.
> > Cheers,
> > Jim.
> > To help you stay safe and secure online, we've
> developed the all new Yahoo! Security Centre.
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
More information about the Mono-devel-list