[Mono-dev] Re: [Mono-devel-list] Limiting Memory Allocation
Jim Purbrick
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
being allocted?
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
general too.
If anyone else has any ideas how best to do this
please let me know.
Cheers,
Jim.
--- Zoltan Varga <vargaz at gmail.com> wrote:
> Hi,
>
> 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
> something.
>
> Zoltan
>
> On 1/18/06, Jim Purbrick <jimpurbrick at yahoo.co.uk>
> wrote:
> > 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
> memory
> > used by different scripts. I basically wrap calls
> to
> > the scripts in calls to the profiler which turn on
> and
> > 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
> other
> > than the memory used by the script and a lot of
> those
> > objects don't seem to be GCed, so a lot of objects
> not
> > allocated by the script end up being counted
> towards
> > the script's memory usage.
> >
> > 2) I end up using a lot of memory to keep
> references
> > to every object allocated by the script so that
> when a
> > GC occurs I can iterate through the list and
> return
> > 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
> by
> > 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
> enough
> > approximation of its memory usage.
> >
> > Cheers,
> >
> > Jim.
> >
> >
> >
> >
> >
>
___________________________________________________________
> > To help you stay safe and secure online, we've
> developed the all new Yahoo! Security Centre.
> http://uk.security.yahoo.com
> > _______________________________________________
> > Mono-devel-list mailing list
> > Mono-devel-list at lists.ximian.com
> >
>
http://lists.ximian.com/mailman/listinfo/mono-devel-list
> >
>
___________________________________________________________
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com
More information about the Mono-devel-list
mailing list