Re: Unloading appdomain and freeing memory
- From: "Champika Nirosh" <test@xxxxxx>
- Date: Thu, 7 Dec 2006 17:56:04 +0600
Hi,
I saw this discussed before here.. under the topic how to unload assembly
and free the memory?
for you I just cut paste important postings..
Once loaded into a particular app domain an assembly cannot be unloaded.
You'd have to create a seperate app domain for each assembly (is this a
plugin thing perhaps) and then unload the app domains when they weren't
needed anymore.
--
Bob Powell [MVP]
Visual C#, System.Drawing
If you do that then why bother with using separate AppDomains? Just exit the
app when you want to free up the memory and unload assemblies
"navyliu" <navyliu@xxxxxxxxxxx> wrote in message
another guy said
I've discussed this problem with my friend and have another idea.
How about making the Assembly Loader as a Com Component?
I haven't test this. But I'll try to solve this problem.
Nirosh.
"RickN" <RickN@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:7F8A9E2D-D531-496D-97E4-2EB470D7A0A7@xxxxxxxxxxxxxxxx
I tried calling GC.Collect() and it does not reclaim the memory. I
verified
all objects created were set to null. An hour later it still has not been
reclaimed.
I think I might have read somewhere that .Net will not release the memory
for anything loaded, even if you unload the appdomain, until the main
process ends, but I can't put my fingers on that information. If it is
true,
it is an unfortunate lack of functionality for .Net, but important to
know,
because while I thought I was conserving memory by unloading the
appdomain,
then reloading it if needed later, I am in fact doubling the memory usage
by
unloading and reloading.
Can anyone verify that .Net 'should' be releasing the memory of a
dynamically loaded and then unloaded appdomain. If so, what's the trick.
If
not, what are the work arounds?
Thanks,
Rick
--
Rick
"Mark R. Dawson" wrote:
Hi RickN,
the memory will not be reclaimed until the Garbage Collector decides
that
it is time to reclaim the memory. If it does not feel that there is any
need
to since there is lots of available memory left then it won't run, it is
undeterministic.
You can force it to run if you want by calling GC.Collect() which will
collect objects from all generations that are eligable for being garbage
collected.
Mark.
--
http://www.markdawson.org
"RickN" wrote:
In my .Net 2.0 project I am creating a new appdomain, loading an
assembly and
then unloading the appdomain when finished.
However, even though the appdomain successfully unloads, the memory it
consumed when being added is not released. In fact, if I load the same
appdomain again, and then unload it, it doubles the amount of memory
consumed.
My main goal is to consume minimal memory, so how do I load a dll,
access
the assembly, unload it when finished, then regain the memory that was
consumed in the process.
Thanks,
Rick
--
Rick
.
- Follow-Ups:
- Re: Unloading appdomain and freeing memory
- From: RickN
- Re: Unloading appdomain and freeing memory
- References:
- RE: Unloading appdomain and freeing memory
- From: RickN
- RE: Unloading appdomain and freeing memory
- Prev by Date: Why use a delegate
- Next by Date: GC.SuppressFinalize?
- Previous by thread: RE: Unloading appdomain and freeing memory
- Next by thread: Re: Unloading appdomain and freeing memory
- Index(es):
Relevant Pages
|