EldoS | Feel safer!

Software components for data protection, secure storage and transfer

Memory Leak PGPBBox7::IElPGPPublicKeyX

Also by EldoS: Rethync
The cross-platform framework that simplifies synchronizing data between mobile and desktop applications and servers and cloud storages
Posted: 03/08/2010 12:48:59
by Christian Paucksch (Standard support level)
Joined: 12/31/2009
Posts: 4


we use PGPBBox7, Microsoft VIsual C++ 6.0. If our test methods run in a loop, they produce memory leak. The reason for this are those three lines:
  PGPBBox7::IElPGPPublicKeyX* pPGPPublicKey = NULL;
  HRESULT hr = CoCreateInstance(CLSID_ElPGPPublicKeyX, NULL,   CLSCTX_INPROC_SERVER, IID_IElPGPPublicKeyX, (void**)&pPGPPublicKey);
  // Here we use pPGPPublicKey
  // .....
  // after using
  if(pPGPPublicKey != NULL) pPGPPublicKey->Release();

What is the correct way to destroy the PGPBBox7::IElPGPPublicKeyX objects in order to avoid memory leaks?

Posted: 03/09/2010 00:54:15
by Eugene Mayevski (EldoS Corp.)

1) How exactly do you measure a memory leak?
2) Did you try creating the key and destroying it right after creation? Does this scenario expose the leak? It can be that not the key object is the source of the problem.

Sincerely yours
Eugene Mayevski
Posted: 03/09/2010 00:57:16
by Ken Ivanov (EldoS Corp.)

Thank you for contacting us.

In most of the cases there's no need to create ElPGPPublicKeyX objects manually (they are usually created and maintained by ElPGPKeyringX object). If you are creating such objects with CoCreateInstance() call, you must call Release() twice. It is quite not obvious, but this is caused by internal architecture of OpenPGPBlackbox. The same is actual for other components managed by ElPGPKeyringX (ElPGPPublicSubkeyX, ElPGPSecretKeyX, ElPGPSecretSubkeyX, ElPGPTrustX, ElPGPSignatureX, ElPGPUserIDX, ElPGPUserAttrX).
Posted: 03/09/2010 13:05:43
by Christian Paucksch (Standard support level)
Joined: 12/31/2009
Posts: 4

Thanks for the prompt answers,

I create ElPGPPublicKeyX objects manually because I get the key content from LDAP. Calling Release() twice resolves the problem.




Topic viewed 958 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!