[Mono-dev] Walking all managed objects
Rodrigo Kumpera
kumpera at gmail.com
Mon Jul 2 16:46:33 EDT 2007
Joachim,
Heap walking is not supported AFAIK. You could, in theory, implement this
feature by extending the garbage collector, but this would require some big
mono hacking, which I think you should avoid.
>From the performance point of view, using finalizer is make for sense for
what you require, since the GC only have to worry about a small bunch of
objects and your application won't perform full heap scan, which is a
operation with a high cost. Using finalizer should be even better once mono
ships with sgen as default. Sgen is a generational garbage collector and
most of time it only scans a fraction of the heap. This means that it would
process finalizers at a lower cost than performing the full heap scans you
have sugested.
Anyway, it's not a good practice to rely on the GC to perform resources
management, as it doesn't provide any hard guarantees about when they will
be freed. This could lead to file descriptor exaction or sub-optimal system
performance. The best way is to let the application do manual resource
management. It's not that hard and produces better result. In your example,
it could have a queue that it's processed at specific times.
Cheers,
Rodrigo Kumpera
On 7/2/07, Joachim Ante <joe at otee.dk> wrote:
>
> Hi,
>
> Is there any way from managed or unmanaged code to iterate through
> all allocated managed objects?
> I presume the Garbage collector must have this data somewhere?
>
> I basically want to see which objects are being referenced and then
> unload some unmanaged data based on it.
> I don't want to override the finalizer for performance reasons. In
> our situation there are specific times where i can just spend a bunch
> of time on cleanup.
>
> Joachim Ante
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070702/59923acf/attachment.html
More information about the Mono-devel-list
mailing list