Solved

Possible memory leak:

Posted on 2004-08-19
2
222 Views
Last Modified: 2010-04-01

      CString cs("Mark IIV");
      DisplayMethod(cs.AllocSysString());

...do I have to do anything with cs to free is due to memory leaks or is that ok?
0
Comment
Question by:Unimatrix_001
2 Comments
 
LVL 8

Accepted Solution

by:
mnashadka earned 200 total points
ID: 11846956
Actually, cs is fine, but the new BSTR that you send to DisplayMethod must be freed with ::SysFreeString.  You'll either want to get the BSTR beforehand so that you can call ::SysFreeString after calling DisplayMethod, or call ::SysFreeString in your DisplayMethod function (if that's an option).  Good luck.
0
 
LVL 3

Author Comment

by:Unimatrix_001
ID: 11847408
Thank you :)
0

Featured Post

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question