Memory leaks after calling IsLicenseGenuine?

Since we added Cryptlex to our C++ application, we get memory leak warnings when running a debug session on Windows 10. I’ve created a minimalistic console application hat only makes calls into the Cryptlex lib, and this too gives rise to the memory leaks. We use the latest Cryptlex static library; version 3.3.0 for Visual Studio 2015. The code is compiled in Visual Studio 2017, but we’re using the 2015 toolchain. We create 64-bit binaries.

I’ve done some tests to exclude possible causes, and what I found out so far, is:

  • all of our own objects etc. get destroyed properly; there are no other memory leaks
  • if we omit the specific call to IsLicenseGenuine (and leave the rest as-is), the memory leak goes away
  • other Cryptlex setup calls give no leaks (SetProductData, SetProductId and SetAppVersion)
  • calling only IsTrialGenuine on an expired trial license (and not IsLicenseGenuine) doesn’t leak any memory
  • extending this trial, then calling StartTrial gave memory leaks again
  • calling only IsTrialGenuine from this point on gave no memory leaks

Could it be that the background thread that is started by Cryptlex to do server verification doesn’t terminate properly when our application closes, causing the memory leaks in turn?

Do you have any insight in what could be at play, and how we can mitigate this?

To set up the source to produce a memory leak report, you can add
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
at the start of the source file, and then call
_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
at the start of your executable’s main code.

The memory leak report we get is:
{94466} normal block at 0x000000002940BF10, 48 bytes long.
Data: 65 34 33 37 31 32 64 34 37 64 36 30 34 61 35 35
{94465} normal block at 0x0000000028288B80, 464 bytes long.
Data: <-----BEGIN PUBLI> 2D 2D 2D 2D 2D 42 45 47 49 4E 20 50 55 42 4C 49
{94464} normal block at 0x000000002940C7D0, 48 bytes long.
Data: 61 33 34 65 63 64 33 37 2D 30 63 31 65 2D 34 31 < this is our product ID
{94463} normal block at 0x000000002940AEE0, 48 bytes long.
Data: <6BEDD0-970CDB-4D> 36 42 45 44 44 30 2D 39 37 30 43 44 42 2D 34 44 < this is the license key used
{94462} normal block at 0x00000000295D1FA0, 16 bytes long.
Data: < U( > C8 13 55 28 00 00 00 00 00 00 00 00 00 00 00 00
{94461} normal block at 0x00000000295D0EC0, 16 bytes long.
Data: < U( > A0 13 55 28 00 00 00 00 00 00 00 00 00 00 00 00
{94460} normal block at 0x00000000295D1BE0, 16 bytes long.
Data: <x U( > 78 13 55 28 00 00 00 00 00 00 00 00 00 00 00 00
{94459} normal block at 0x00000000295D1A00, 16 bytes long.
Data: <P U( > 50 13 55 28 00 00 00 00 00 00 00 00 00 00 00 00
{94458} normal block at 0x0000000028551350, 168 bytes long.
Data: < ]) @) > 00 1A 5D 29 00 00 00 00 E0 AE 40 29 00 00 00 00

Hi Carl,

Thanks for the detailed analysis. We use Visual Leak Detector which had not reported any memory leaks.

We will again look into this for possible causes.

Memory leak only happens till process is running, when the process exits, all the memory is freed (including the memory leaked by the process) - https://stackoverflow.com/questions/2975831/is-leaked-memory-freed-up-when-the-program-exits

How much memory leak did you observe for the number of times the IsLicenseGenuine() is called?

Hi Support,

The leak dump information I posted above is the only thing being reported, so it’s not that much in total. Repeated calls to IsLicenseGenuine in a short test run didn’t produce longer dumps, but longer test runs did give rise to longer dumps - IIRC I called other functions in that trial run as well (like license activations + deactivations, followed by more IsLicenseGenuines etc.). I can try to reproduce such a longer run if you want?

Carl,

Thanks a lot. I would recommend checking the memory usage in the process manager too.

We will also test it and will keep you posted.

Thanks again for reporting the issue.