Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

resource leak in CreateSolidBrush

Posted on 2003-10-30
3
Medium Priority
?
444 Views
Last Modified: 2013-11-20
What is wrong with this code?

CodeSnitch of Entrek (utility that allows profiling WinCE) emphasise the line with CreateSolidBrush as a resourse leak.

Assuming that in my test application there is no use of the m_Brush, this leak is really weird.

Can you explane it?

CPOEApp::CPOEApp(LPCTSTR lpszAppName): CWinApp(lpszAppName)

{

    m_Brush.CreateSolidBrush(TOP_LABEL_COLOR); //resource leak

}

CPOEApp::~CPOEApp()

{

    m_Brush.DeleteObject();

}

Stas K
0
Comment
Question by:stkash
3 Comments
 
LVL 48

Accepted Solution

by:
AlexFM earned 250 total points
ID: 9650254
It's OK even without call to DeleteObject, since it is deleted in CBrush destructor.
There are 3 types of memory leak messages in the tools like CodeSnitch:

1) Points to your error
2) Points to error is some other code you are using - there is nothing to do
3) No error at all.

I guess this is of type 3.
0
 
LVL 8

Expert Comment

by:martynjpearson
ID: 9650652
Are you getting a memory leak too? It could be that the object that contains the brush is not being deleted, hence you would get a resource leak.

All the best
Martyn
0
 

Author Comment

by:stkash
ID: 9650664
no, I get only the resource leak
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Loops Section Overview

926 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