Solved

resource leak in CreateSolidBrush

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
xyBalance chalenge 58 88
sumDigits challenge 9 96
isEverywhere  challenge 19 64
wordappend challenge 8 85
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

707 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

15 Experts available now in Live!

Get 1:1 Help Now