Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET MemUsage skyrockets when unzipping files

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #20037 |

    Here is my code:

     

    private void ExtractToTempFolder(string sourcePath)
            {
                ZipArchive fileAsZip = new ZipArchive(new DiskFile(sourcePath));
                MemoryFolder folder = new MemoryFolder(“MemoryDrive”, @”\”);
                fileAsZip.CopyFilesTo(folder, true, true);

                MemoryFolder subFolder = folder.GetFolder(@”path omitted here”) as MemoryFolder;

                DiskFolder tempFolder = new DiskFolder(tempDirectory);
                subFolder.CopyFilesTo(tempFolder, true, true, new NameFilter(“filter omitted here – but gets 8 files from the folder”));
            }

     

    I am taking a ZIP file, and extracting out 8 files to a physical directory on my PC.

    When this runs, it’s like it doesn’t release the memory.  So when I watch my app in Task Manager, MemUsage just keeps going up every time this method is called. 

    Any suggestions?

    Imported from legacy forums. Posted by Hillarie (had 1041 views)

    User (Old forums)
    Member
    Post count: 23064

    Your issue is specific to you, and we would need to reproduce it to understand the what’s happening.  However this would require us to invest time on it, and for us to allocate time on your issue would require you to have an active vanguard support subscription, which you can contact our sales department at sales@xceed.com for more information.  If you already are a vanguard subscriber, please send us an email at support@xceed.com.

    Alternatively your post will remain on the forums viewable to the community to comment and suggest solutions.

     

     

    Imported from legacy forums. Posted by André (had 370 views)

    User (Old forums)
    Member
    Post count: 23064

    We investigated this further through an email thread with Hillarie.  We found that MemoryFolder and MemoryFile need to be erased after being done with them, and calling the Garbage Collector will release the memory.  The reason for this is that MemoryFolder and MemoryFile are implemented a bit like a file on disk, that it, if you set a reference to a DiskFile to null, the file will still exist on disk, you can reference it later in your application.  If you make a new MemoryFolder with the same name later in your application, the folder (and files in it) will be there.

    Here is an example of what needs to be done :

    static void MemoryFolderTest()
    {
      MemoryFolder folder = new MemoryFolder( “MemoryDrive”, “\\” );
      DiskFile file = new DiskFile( @”someFile” ); // in this case, a 3.89MB file

      for( int i = 0; i < 100; i++ )
      {
        file.CopyTo( folder.GetFile( i.ToString() ), true );
      }

      file = null;

      for( int i = 0; i < 100; i++ )
      {
        folder.GetFile( i.ToString() ).Delete();
      }

      folder = null;

      GC.Collect();
    }

    Imported from legacy forums. Posted by André (had 1330 views)

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.