User (Old forums)MemberDecember 1, 2006 at 3:16 pmPost count: 23064
When is the memory used to store zip files released? Does this happen when the method or program ends, or do I need to call something to release the memory?
Imported from legacy forums. Posted by Drew (had 3507 views)User (Old forums)MemberDecember 4, 2006 at 1:44 pmPost count: 23064
It depends what you are referring to.
If you refer to the data of each file that is zipped, the memory used by the compressor to actually build the archive and place the compressed data into it is released as soon as the compression is done.
If you refer to the local/central header information for each file contained in the archive, it is released when the zip object (ZipArchive) is released, for example when the method where it is declared exits, AND the Garbage Collector has collected the memory associated with the object.
Imported from legacy forums. Posted by André (had 278 views)User (Old forums)MemberDecember 4, 2006 at 1:46 pmPost count: 23064
Thanks for the response.
How do I call the Garbage Collector to collect the memory associated with the object?
Imported from legacy forums. Posted by Drew (had 321 views)User (Old forums)MemberDecember 4, 2006 at 2:15 pmPost count: 23064
First, you don’t need to call the Garbage Collector, the .NET framework does it for yourself.
Second, if you still want to call it, use System.GC.Collect().
Third, on objects that implement the IDisposable interface (which is NOT the case of ZipArchive), you can call Dispose() on the object, which will free resources associated with the object.
Fourth, some reading on Garbage Collection may be helpful, to make sure your not creating more problem with calling the GC yourself.
The following is a discussion on the Compact Framework, but still applies to this discussion :
Look for the heading “What are the ramifications of calling GC.Collect()?”.
Imported from legacy forums. Posted by André (had 229 views)
- You must be logged in to reply to this topic.