[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Possible memory leak:

Posted on 2004-08-19
2
Medium Priority
?
237 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 800 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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. …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

867 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