Solved

resource leak in CreateSolidBrush

Posted on 2003-10-30
3
412 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 125 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Suggested Solutions

Title # Comments Views Activity
bobThere java chalenge 45 94
Macro to save highlighted rows as a separate file 5 45
Process filename extension 3 196
VBA "SendKeys" Syntax for Multiple Keystrokes 7 117
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.

821 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