0
votes

I have client/server app. Interaction implemented via Boost.Asio.

I created unit test to check long running transmission of data. During the test memory leak detected. Task Manager shows me that memory usage constantly grows - up to 35MB per 10min. Report produced at the end of test contains this:

Result StandardError:   Detected memory leaks!
Dumping objects ->
{14522} normal block at 0x00E8ADC0, 16 bytes long.
 Data: < _M} Y          > B0 5F 4D 7D F9 59 F2 02 F4 E9 E6 00 CC CC CC CC 
{14012} normal block at 0x00E8B280, 16 bytes long.
 Data: < v              > C0 76 A4 00 94 01 00 00 98 01 00 00 F0 D2 E3 00 
{14011} normal block at 0x00E74B38, 12 bytes long.
 Data: <            > 00 00 00 00 9C 01 00 00 98 01 00 00 
{14007} normal block at 0x00E745F8, 8 bytes long.
 Data: < L      > E0 4C E5 00 00 00 00 00 
{14006} normal block at 0x00E54CB8, 60 bytes long.
 Data: < v          4   > E4 76 A4 00 D0 D3 B0 00 00 00 00 00 34 80 E3 00 
{13724} normal block at 0x00E710F8, 385 bytes long.
 Data: <                > 03 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 
{13722} normal block at 0x00E85C58, 28 bytes long.
 Data: <  F  _   _      > F2 B6 46 00 B4 5F E3 00 A0 5F E3 00 BC 96 E7 00 
{13720} normal block at 0x00E6F9B8, 80 bytes long.
 Data: <wxF             > 77 78 46 00 FC FF FF FF 00 00 00 00 CC CC CC CC 
{13700} normal block at 0x00E6DFD0, 88 bytes long.
 Data: <                > C8 A4 A4 00 01 00 00 00 01 00 00 00 00 00 00 00 
…
 Data: <`   X    L  > 60 8E E0 00 58 17 E2 00 CD 4C F7 EA 
{153} normal block at 0x00DF0070, 12 bytes long.
 Data: <`        kf > 60 8D E0 00 98 00 E2 00 15 6B 66 0E 
{151} normal block at 0x00DF0038, 12 bytes long.
 Data: <          .g> 20 86 E0 00 E0 FC E1 00 9D B7 2E 67 
{149} normal block at 0x00DF0658, 12 bytes long.
 Data: <        G   > A0 89 E0 00 00 00 00 00 47 01 D5 11 
{147} normal block at 0x00DF0268, 12 bytes long.
 Data: <`           > 60 84 E0 00 A8 F5 E1 00 ED 8C AA BA 
{145} normal block at 0x00DF0230, 12 bytes long.
 Data: <        ' " > 20 84 E0 00 00 11 E2 00 27 B0 22 00 
{143} normal block at 0x00DF0690, 12 bytes long.
 Data: <`   P   KnOQ> 60 88 E0 00 50 04 E2 00 4B 6E 4F 51 
{141} normal block at 0x00DF0540, 12 bytes long.
 Data: <`       >  7> 60 82 E0 00 00 0A E2 00 3E 0D 9E 37 
{139} normal block at 0x00DF0620, 12 bytes long.
 Data: <Pq        1 > 50 71 DF 00 00 00 00 00 E5 DD 31 B5 
{137} normal block at 0x00DF0700, 12 bytes long.
 Data: < q  @      #> 10 71 DF 00 40 FA E1 00 14 8B 0D 23 
{134} normal block at 0x00DF5CE0, 96 bytes long.
 Data: <h    BV  BV     > 68 19 E0 00 D0 42 56 00 E0 42 56 00 88 00 00 00 
{133} normal block at 0x00DF0188, 8 bytes long.
 Data: < \      > A0 5C DF 00 00 00 00 00 
{132} normal block at 0x00DF5CA0, 16 bytes long.
 Data: <                > 88 01 DF 00 D8 AA DF 00 20 AC DF 00 20 AC DF 00 
Object dump complete.

I tried to put breakpoint to mentioned memory allocations via boost's --detect_memory_leaks="allocation number" and setting in Watch window at Debug mode _crtBreakAlloc = 1000. It does not work. Maybe because leaks occur not in my code, but in boost/OpenSSL code?

I can't figure out where leaks occur. What can I do?

Windows 8, Visual Studio 2015, boost 1.60, OpenSSL 1.0.2g

2
You should post your actual source code if you want a more definitive answer.Xirema

2 Answers

0
votes

Have a look at this post to see some suggested tips for dealing with memory leaks under windows. Have a scroll down, don't just look at the first answer. In particular it may be worth considering the DEBUG_NEW macro-based solution discussed by the second answer. Given that boost asio is largely header-only, this should help you even if the offending allocations come from the boost library.

0
votes

Part 1: Report from Visual Studio about memory leaks

I'm using Boost.Asio to communicate with the server over TLS, i.e. Boost.Asio uses OpenSSL.

Seems that OpenSSL initializes itself and do not cleans memory before the end of the app (because app closes and memory will be released anyway). This is not big chunk of memory (I do not know how to measure it).

As result Visual Studio treated that memory as leak. But it is not.

(This is my assumption, maybe real reason for such report is smth else. But I do not see any other possible reasons. )

Part 2:

In the question above I asked about memory leak for tens of Mb. This is my bad code that leads to huge memory buffer )).

Huge memory consumption and report from VisualStudio about memory leak made me believe that smth is very wrong ))

Buffer easily reduced to much smaller size.