EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Memory Leak?

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#19791
Posted: 04/16/2012 02:49:29
by Lam Soon Kin (Basic support level)
Joined: 04/16/2012
Posts: 6

Hi,

We used .Net version OpenPGPBBox. The following codes produce memory leak.

for (int i = 0; i < loop; i++)
{
TElPGPWriter pgpWriter = new TElPGPWriter();
pgpWriter.Dispose();
}

is this the correct way to dispose PGPWriter?
#19792
Posted: 04/16/2012 02:53:00
by Vsevolod Ievgiienko (EldoS Corp.)

Thank you for contacting us.

How did you check that it produces memory leak? Yes this is a correct way to dispose it.
#19793
Posted: 04/16/2012 02:59:16
by Lam Soon Kin (Basic support level)
Joined: 04/16/2012
Posts: 6

The code is running in Win CE 6.0. We use .NETCF Remote Performance Monitor and plot the memory usage grapf on perfmon.exe
#19794
Posted: 04/16/2012 03:05:23
by Vsevolod Ievgiienko (EldoS Corp.)

Could you also clarify what version of SecureBlackbox do you use?
#19795
Posted: 04/16/2012 03:12:10
by Lam Soon Kin (Basic support level)
Joined: 04/16/2012
Posts: 6

SecureBlackbox version 9.1.215 - Released February 20, 2012
#19796
Posted: 04/16/2012 03:36:42
by Eugene Mayevski (EldoS Corp.)

If you have a license, please assign the license ticket to your user account before we continue. The ticket itself and the procedure of it's use are specified in the registration e-mail that was sent to you upon license purchase.


Sincerely yours
Eugene Mayevski
#19797
Posted: 04/16/2012 03:50:04
by Lam Soon Kin (Basic support level)
Joined: 04/16/2012
Posts: 6

We don't have a license yet. Currently we are use a trial key for SecureBBox for evaluation.
#19798
Posted: 04/16/2012 04:08:28
by Eugene Mayevski (EldoS Corp.)

There's no leak happening on desktop so whatever problem is, it's specific to .NET CF. We will check the issue on .NET CF a bit later (today or tomorrow).

Also, is there sense in allocating multiple objects? In most usage scenarios you can use one or several objects to do the job and reuse them when the need arises.


Sincerely yours
Eugene Mayevski
#19799
Posted: 04/16/2012 04:58:51
by Lam Soon Kin (Basic support level)
Joined: 04/16/2012
Posts: 6

I have tried to reuse the same PGPWritter to sign several files (about 20kB to 1 MB). The application memory usage increase significantly and throw out "OutOfMemoryException" just a few cycles.

Code

// PGP writer
pgpWriter = new TElPGPWriter();
pgpWriter.OnKeyPassphrase += new SBPGPStreams.TSBPGPKeyPassphraseEvent(pgpWriter_OnKeyPassphrase);

// compression
pgpWriter.Compress = true;
pgpWriter.CompressionAlgorithm = SBPGPConstants.Unit.SB_PGP_ALGORITHM_CM_ZLIB;
pgpWriter.CompressionLevel = 9; // highest

// signing key
pgpWriter.SigningKeys = secKeyring;
pgpWriter.SignBufferingMethod = SBPGP.TSBPGPSignBufferingMethod.sbmRewind;

for (int i = 0; i < loop; i++)
{
// create file stream
// ...

pgpWriter.SignFiles(srcStringList, srcStreamList, desDir, desStream);

// dispose
// ...
}

pgpWriter.Dispose();


Hope this will help and thanks for the quick response.
#19800
Posted: 04/16/2012 05:42:36
by Eugene Mayevski (EldoS Corp.)

*Files() methods (including SignFiles) don't call Close() on streams and rely on garbage collector. This causes late disposal of resources. At the same time it looks like .NET CF doesn't collect garbage properly or in time. As a solution you can either avoid using *Files() methods, or try to call GC.Collect() after calling SignFiles().

We will address the problem of not calling Close() in the next build of SecureBlackbox, but this won't necessarily solve timely garbage collection problem. It is possible that managed resources (byte arrays allocated for buffers and helper objects) are not collected for whatever reason and that calling GC.Collect() is the only solution on .NET CF.


Sincerely yours
Eugene Mayevski
Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.

Reply

Statistics

Topic viewed 2474 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!