Solved

resource leak in CreateSolidBrush

Posted on 2003-10-30
3
404 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Different colored text in ComboBox without Subclassing 8 55
Unix / Linux grid computing 5 148
java ^ examples 8 62
Problem to event 3 78
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

920 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now