?
Solved

Possible memory leak:

Posted on 2004-08-19
2
Medium Priority
?
236 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Tech or Treat!

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
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 be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

649 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