Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaks when inlcuding the libary in MFC project #99

Open
BasConijn opened this issue Mar 18, 2016 · 12 comments
Open

Memory leaks when inlcuding the libary in MFC project #99

BasConijn opened this issue Mar 18, 2016 · 12 comments

Comments

@BasConijn
Copy link

I have created an test MFC project to remove every dependency. cpprest.zip. Compiled with visual studio 2013.
I have added the project using NuGet.

After executing the project visual studio reports a lot of memory leaks.
I have added visual leak detector, but that reports no leaks (First two lines of the pastebin).
See http://pastebin.com/KdLDtAf6.
Adding the cpprest120d_2_8.dll to the delayed dll import (linker->input) solves most of the leaks (only leaks of #67 remain).

However, I receive "cannot delay load 'cpprest120d_2_8.dll' " when using the http_client class.

When uncommenting the "CreateRequest" functions, even more memory leaks happen.
These are also reported by Visual Leak Detector.
See http://pastebin.com/wGWdEuBB

Anyone knows where the leaks are coming from or how I can ignore them?

@BasConijn BasConijn changed the title Memory leaks when inlcuding the libary in MFC prokect Memory leaks when inlcuding the libary in MFC project Mar 21, 2016
@nathan-gilbert
Copy link

Did you ever find a solution to this problem?

@BasConijn
Copy link
Author

Nope. I am not sure where to look though.

@Yavathar
Copy link

Yavathar commented Oct 12, 2016

I'm experiencing the same memory leaks.
What I have in my codes are

  1. including the head file
    #include <cpprest\http_client.h>
  2. in my class' method,
    unsigned int CMy::http_post() { web::http::http_request requestGCM(L"POST"); return 0; }
    Actually In runtime my codes never call the above method. But, when my program ends, a lot of memory leaks are found.

I wonder this issue will be fixed by someone?

[Adding comments]
The memory leaks happen when I test with web::json::value.
I only declared a valable, jsonBody like;
web::json::value jsonBody;
in a function that I've never called in my code.

@Curry-Messi
Copy link

You try

Project Properties
Linker->Input->Add library dependencies
mfc120ud.lib;mfcm120ud.lib

@PversusNP
Copy link

I have the same problem.
I compiled cpprest140 source (version 2.10.2) with visual studio 2015 for Win32.
I linked it in my MFC project and if I run the application, without calling any cpprest api, when I stop I get memory leaks.
What's the solution?
Thanks.

@yzxandfcm
Copy link

I have the same problem. How can fix this issue

@Curry-Messi
Copy link

Curry-Messi commented May 12, 2020 via email

@yzxandfcm
Copy link

yzxandfcm commented May 12, 2020 via email

@Currywurst
Copy link

Hi, we have an large Multibyte MFC Project and we also get the FALSE Positive leaks.
We can not simply add the MFC Unicode libs.
I tryed to compile the cppRestSDK manually and link it as static, but then we have too many other issues ( with libz and more ).

Did anyone have an solution or an idea? What can we do to solve this problem?

@Curry-Messi
Copy link

嗨,我们有一个大型的多字节MFC项目,并且我们还得到了FALSE Positive泄漏。
我们不能简单地添加MFC Unicode库。
我尝试手动编译cppRestSDK并将其链接为静态链接,但是随后我们遇到了太多其他问题(libz等问题)。

有没有人有解决方案或想法?我们该怎么做才能解决这个问题?
微信图片_20200611092426

My vs2017 MFC LIBS path is "Microsoft Visual Studio 14.0 \ VC \ atlmfc \ lib".
mfcxxx.lib before MFCMxxx.lib , this is very important

@Aero9999
Copy link

Aero9999 commented Nov 2, 2022

I think this is because the statics in cpprest are cleared up after MFC calls _CrtDumpMemoryLeaks(), its a false positive.

The solution described here worked for me:
https://groups.google.com/g/microsoft.public.vc.mfc/c/c0k93sFlpcs#e651b944da9c619d

I had to compile my own version of cpprest though with that new class.

@tmd9936
Copy link

tmd9936 commented Dec 5, 2024

It's right.
But multibyte mfc project must link "mfc120d.lib;mfcm120d.lib"

I solved problem this way

You try

Project Properties
Linker->Input->Add library dependencies
mfc120ud.lib;mfcm120ud.lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants