PGP SDK memory leak

PGP SDK memory leak

Post by delis.. » Tue, 13 Nov 2001 19:57:40



hi

Not sure i'm sending this to the right group. Apologies if not.

I'm developing a simple COM component to do PGP ecnryption/decryption
using the PGP SDK. I think there is a memory leak in the function
PGPFreeKeySet.

Basically, when i call PGPOpenDefaultKeyRings, the memory usage in the
Win2K task manager goes up by about 8K. When I call PGPFreeKeySet,
i would have expected the usage to go down again but instead it goes
UP by another 8K!!!

Am i doing something wrong or is there a memory leak?? either way how
do i get round it??

thanks for any help in advance

Scott Gilhooly

 
 
 

PGP SDK memory leak

Post by Johan Wever » Tue, 13 Nov 2001 20:38:15



> I'm developing a simple COM component to do PGP ecnryption/decryption
> using the PGP SDK. I think there is a memory leak in the function
> PGPFreeKeySet.
> Basically, when i call PGPOpenDefaultKeyRings, the memory usage in the
> Win2K task manager goes up by about 8K. When I call PGPFreeKeySet,
> i would have expected the usage to go down again but instead it goes
> UP by another 8K!!!
> Am i doing something wrong or is there a memory leak?? either way how
> do i get round it??

It could be a memory leak, but this does not prove it. Memory usage in
the task manager can also go up by a program requesting memory and win2k
keeping more memory reserved for it just in case it might ask for it
again, then the requesting program gets the memory faster. This is some
speed optimization from windows itself. If this is the case in your
situation can be tested with some extra code. For the background, see:

http://msdn.microsoft.com/library/psdk/winbase/prothred_07l1.htm

Look at these options:

If both dwMinimumWorkingSetSize and dwMaximumWorkingSetSize have the
value -1, the function temporarily trims the working set of the specified
process to zero. This essentially swaps the process out of physical RAM
memory.

Add these lines before and after your call to PGPFreeKeySet() and check
in the taskmanager what happens with the memory. If the memory usage is
still higher afterward you have probably found a memory leak.

HANDLE HCurrentProc; /* declare once in your function or global */

HCurrentProc = GetCurrentProcess();
SetProcessWorkingSetSize(HCurrentProc, -1 ,-1);

--
ir. J.C.A. Wevers         //  Physics and science fiction site:

PGP/GPG public keys at http://www.xs4all.nl/~johanw/pgpkeys.html

 
 
 

PGP SDK memory leak

Post by Johan Wever » Tue, 13 Nov 2001 20:41:37



> http://msdn.microsoft.com/library/psdk/winbase/prothred_07l1.htm

Oops, sorry, just found out this is a dead link. But giving
SetProcessWorkingSetSize in the search field on the msdn.microsoft.com
site will result in some usefull links.

--
ir. J.C.A. Wevers         //  Physics and science fiction site:

PGP/GPG public keys at http://www.xs4all.nl/~johanw/pgpkeys.html

 
 
 

PGP SDK memory leak

Post by delis.. » Tue, 13 Nov 2001 21:06:13




>Add these lines before and after your call to PGPFreeKeySet() and check
>in the taskmanager what happens with the memory. If the memory usage is
>still higher afterward you have probably found a memory leak.

>HANDLE HCurrentProc; /* declare once in your function or global */

>HCurrentProc = GetCurrentProcess();
>SetProcessWorkingSetSize(HCurrentProc, -1 ,-1);

I tried this but it made no difference. The memory use STILL rockets.

When testing this, repeated calls to the component show the memory use
going up and up. Presumable any windows "optimisation" would have
eventually let go or stopped grabbing more memory????

scott

 
 
 

PGP SDK memory leak

Post by Rober » Wed, 14 Nov 2001 09:42:41


Quote:> I'm developing a simple COM component to do PGP ecnryption/decryption
> using the PGP SDK. I think there is a memory leak in the function
> PGPFreeKeySet.
> Basically, when i call PGPOpenDefaultKeyRings, the memory usage in the
> Win2K task manager goes up by about 8K. When I call PGPFreeKeySet,
> i would have expected the usage to go down again but instead it goes
> UP by another 8K!!!

Win2K task manager is not a measure of accurate memory usage of an
application.

The 1.7.x SDK included debug builds of the SDK dll's so you would get an
assertion on application shut down if memory was not freed. Try putting
these Dll's in your application directory.

 
 
 

PGP SDK memory leak

Post by delis.. » Wed, 14 Nov 2001 19:06:52




Quote:>Win2K task manager is not a measure of accurate memory usage of an
>application.

true, but it does show the memory giong from 2Mb to as high as 30
after about 15 minutes of use. When it was left running overnight, the
server ground to a halt through lack of free memory.

Quote:>The 1.7.x SDK included debug builds of the SDK dll's so you would get an
>assertion on application shut down if memory was not freed. Try putting
>these Dll's in your application directory.

The memory is freed when the component is shut down but as this
component will be running 24/7 i need it to let go of memory sooner
i.e. when i call PGPFreeKeySet. This function doesn't seem to make any
difference to teh memroy usage. Is there another way round this??
 
 
 

PGP SDK memory leak

Post by Rob » Wed, 14 Nov 2001 20:19:35



Quote:> The memory is freed when the component is shut down but as this
> component will be running 24/7 i need it to let go of memory sooner
> i.e. when i call PGPFreeKeySet. This function doesn't seem to make any
> difference to teh memroy usage. Is there another way round this??

No idea, post a simplified app which displays this behaviour.

Follow Ups set to c.s.pgp.tech

 
 
 

1. Memory Leak in pgp

I am using PGP SDK from Network Associates to Encrypt and Decrypt files.
When I run my program on NT through purify, it shows a memory leak of
8224 Bytes in function IsdGetStatistic in PGP_SDK.DLL. I am having the
same problem on Linux. You can easily simulate the problem using the
test progam which comes with the SDK.  Has anyone experienced this
problem ??  Is there any patch I can download to fix the above problem
??

2. Directory Listing

3. Memory Leak/Finding Available Memory

4. Query foreign database: is it possible?

5. Dos file system memory leak and Memory fragmentation

6. Dealing With Phone Tampering

7. PGP 7 - Error on Win2K- "Cannot connect to the PGP SDK service"

8. send file with mail

9. PGP 7.0.3 / NT 4.0 PGP SDK service cannot start error

10. PGP SDK - We must install PGP sofware ????

11. Xsgi & Memory (Was: Re: Memory leak ?)

12. Memory problem... (possibly big memory leak ?).

13. Eudora/PGP plaintext leak