microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
8.02k stars 1.65k forks source link

Memory leaks when running tutorial code #801

Open Thread-Ripper opened 6 years ago

Thread-Ripper commented 6 years ago

Hi all, My first post here since I am just trying to learn to use the cpprestsdk. Running VS2013 I created a console application (MFC) and went to the nuget package manager and installed the cpprestsdk - version 2.9.1 (the latest available there). Read through the official beginner's tutorial and pasted the code into a function.

The sample works well in practice as I do get HTML results written to the results.html file. So far so good. However, as the application is closed I get loads of memory leaks according to Visual Studio output window. Here are some of them (perhaps 1% of them or so):

Detected memory leaks!
Dumping objects ->
{3813} normal block at 0x00E29788, 48 bytes long.
 Data: <S e c - W e b S > 53 00 65 00 63 00 2D 00 57 00 65 00 62 00 53 00 
{3812} normal block at 0x00E1E358, 8 bytes long.
 Data: <        > D8 DA F7 0F 00 00 00 00 
{3811} normal block at 0x00E26A60, 16 bytes long.
 Data: <                > 00 00 00 00 07 00 00 00 08 00 00 00 0D 00 00 00 
{3810} normal block at 0x00E1E048, 8 bytes long.
 Data: <        > C8 DA F7 0F 00 00 00 00 
{3809} normal block at 0x00E28080, 80 bytes long.
 Data: <ABCDEFGHIJKLMNOP> 41 42 43 44 45 46 47 48 49 4A 4B 4C 4D 4E 4F 50 
{3808} normal block at 0x00E1DFD8, 8 bytes long.
 Data: <        > 90 DA F7 0F 00 00 00 00 
{3807} normal block at 0x00E1E010, 8 bytes long.
 Data: <t       > 74 DA F7 0F 00 00 00 00 
{3806} normal block at 0x00E29968, 48 bytes long.
 Data: <R e s p o n s e > 52 00 65 00 73 00 70 00 6F 00 6E 00 73 00 65 00 
{3805} normal block at 0x00E1E208, 8 bytes long.
 Data: <        > 08 D9 F7 0F 00 00 00 00 
{3804} normal block at 0x00E29068, 48 bytes long.
 Data: <W w w - A u t h > 57 00 77 00 77 00 2D 00 41 00 75 00 74 00 68 00 
{3803} normal block at 0x00E1DF30, 8 bytes long.
 Data: <        > EC D8 F7 0F 00 00 00 00 
{3802} normal block at 0x00E1D6E0, 8 bytes long.
 Data: <        > D0 D8 F7 0F 00 00 00 00 
{3801} normal block at 0x00E2AE80, 32 bytes long.
 Data: <S e t - C o o k > 53 00 65 00 74 00 2D 00 43 00 6F 00 6F 00 6B 00 
{3800} normal block at 0x00E1D600, 8 bytes long.
 Data: <        > B4 D8 F7 0F 00 00 00 00 
{3799} normal block at 0x00E1D6A8, 8 bytes long.
 Data: <        > 98 D8 F7 0F 00 00 00 00 
{3798} normal block at 0x00E2AD40, 32 bytes long.
 Data: <R e t r y - A f > 52 00 65 00 74 00 72 00 79 00 2D 00 41 00 66 00 
{3797} normal block at 0x00E1DC90, 8 bytes long.
 Data: <|       > 7C D8 F7 0F 00 00 00 00 
{3796} normal block at 0x00E294E8, 48 bytes long.
 Data: <P r o x y - A u > 50 00 72 00 6F 00 78 00 79 00 2D 00 41 00 75 00 
{3795} normal block at 0x00E1DB78, 8 bytes long.
 Data: <`       > 60 D8 F7 0F 00 00 00 00 
{3794} normal block at 0x00E2AF20, 32 bytes long.
 Data: <L o c a t i o n > 4C 00 6F 00 63 00 61 00 74 00 69 00 6F 00 6E 00 
{3793} normal block at 0x00E1DC20, 8 bytes long.
 Data: <D       > 44 D8 F7 0F 00 00 00 00 
{3792} normal block at 0x00E1DBB0, 8 bytes long.
 Data: <(       > 28 D8 F7 0F 00 00 00 00 
{3791} normal block at 0x00E1D7C0, 8 bytes long.
 Data: <        > 0C D8 F7 0F 00 00 00 00 
{3790} normal block at 0x00E2AE30, 32 bytes long.
 Data: <A c c e p t - R > 41 00 63 00 63 00 65 00 70 00 74 00 2D 00 52 00 
{3789} normal block at 0x00E1D7F8, 8 bytes long.
 Data: <        > F0 D7 F7 0F 00 00 00 00 
{3788} normal block at 0x00E2AB10, 32 bytes long.
 Data: <R e q u e s t - > 52 00 65 00 71 00 75 00 65 00 73 00 74 00 2D 00 
{3787} normal block at 0x00E1D8A0, 8 bytes long.
 Data: <        > D4 D7 F7 0F 00 00 00 00 
{3786} normal block at 0x00E2ADE0, 32 bytes long.
 Data: <U s e r - A g e > 55 00 73 00 65 00 72 00 2D 00 41 00 67 00 65 00 
{3785} normal block at 0x00E1DB40, 8 bytes long.
 Data: <        > B8 D7 F7 0F 00 00 00 00 
{3784} normal block at 0x00E2AFC0, 32 bytes long.
 Data: <T r a n s l a t > 54 00 72 00 61 00 6E 00 73 00 6C 00 61 00 74 00 
{3783} normal block at 0x00E1DAD0, 8 bytes long.
 Data: <        > 9C D7 F7 0F 00 00 00 00 
{3782} normal block at 0x00E1D638, 8 bytes long.
 Data: <        > 80 D7 F7 0F 00 00 00 00 
{3781} normal block at 0x00E1D868, 8 bytes long.
 Data: <d       > 64 D7 F7 0F 00 00 00 00 
{3780} normal block at 0x00E1DA98, 8 bytes long.
 Data: <H       > 48 D7 F7 0F 00 00 00 00 
{3779} normal block at 0x00E29188, 48 bytes long.
 Data: <P r o x y - A u > 50 00 72 00 6F 00 78 00 79 00 2D 00 41 00 75 00 
{3778} normal block at 0x00E1D9B8, 8 bytes long.
 Data: <,       > 2C D7 F7 0F 00 00 00 00 
{3777} normal block at 0x00E2ACA0, 32 bytes long.
 Data: <M a x - F o r w > 4D 00 61 00 78 00 2D 00 46 00 6F 00 72 00 77 00 
{3776} normal block at 0x00E1DC58, 8 bytes long.
 Data: <        > 10 D7 F7 0F 00 00 00 00 
{3775} normal block at 0x00E293C8, 48 bytes long.
 Data: <I f - U n m o d > 49 00 66 00 2D 00 55 00 6E 00 6D 00 6F 00 64 00 
{3774} normal block at 0x00E1D8D8, 8 bytes long.
 Data: <        > F4 D6 F7 0F 00 00 00 00 
{3773} normal block at 0x00E2AAC0, 32 bytes long.
 Data: <I f - R a n g e > 49 00 66 00 2D 00 52 00 61 00 6E 00 67 00 65 00 
{3772} normal block at 0x00E1D980, 8 bytes long.
 Data: <        > D8 D6 F7 0F 00 00 00 00 
{3771} normal block at 0x00E2AED0, 32 bytes long.
 Data: <I f - N o n e - > 49 00 66 00 2D 00 4E 00 6F 00 6E 00 65 00 2D 00 
{3770} normal block at 0x00E1DA60, 8 bytes long.
 Data: <        > BC D6 F7 0F 00 00 00 00 
{3769} normal block at 0x00E29488, 48 bytes long.
 Data: <I f - M o d i f > 49 00 66 00 2D 00 4D 00 6F 00 64 00 69 00 66 00 
{3768} normal block at 0x00E1DB08, 8 bytes long.
 Data: <        > A0 D6 F7 0F 00 00 00 00 
{3767} normal block at 0x00E2AC50, 32 bytes long.
 Data: <I f - M a t c h > 49 00 66 00 2D 00 4D 00 61 00 74 00 63 00 68 00 
{3766} normal block at 0x00E1D5C8, 8 bytes long.
 Data: <        > 84 D6 F7 0F 00 00 00 00 

I tried creating a new project using a dialog based MFC application. Same results. I tried VS2015 (which I won't be able to use in production though). Same result.

I wanted to download the latest version 2.10.2 but VS2013 support was dropped in version 2.10? Also I cannot use vcpkg package manager because its prerequisites include VS2017 or VS2015 Update 3?

I believe that a beginner's tutorial should not leak memory, so something is wrong. But what? Thankful for help!

EDIT: I should mention I am compiling for x64 Windows Desktop

yzxandfcm commented 4 years ago

I have the same problem. How can fix this issue