424,298 Members | 1,854 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,298 IT Pros & Developers. It's quick & easy.

GDI Leaks Detection

Jurnero
P: 32
Hello! Several times I had a problem with GDI-objects leak.
My colleagues helped me solve the problem. But I would like to ask for help! How are you searching this type of leak? What utilities or plugins for VS can help me?

Programming language: C++. Visual Studio
Nov 14 '18 #1
Share this Question
Share on Google+
8 Replies


weaknessforcats
Expert Mod 5K+
P: 9,197
Are you using C or C++ ?

You use managed pointers aka smart pointers.

It's harder n C since you need to set up your own reference counters.

Then you create these objects using a function that increments the reference count.

You delete using a function that decrements the reference count and deletes the object if the count is zero.

In C++ it is handled using managed pointer objects which contain a reference to the object being managed.

In today's world you should never be using naked pointers anywhere.
Nov 14 '18 #2

Jurnero
P: 32
Thanks for the answer.
Added details to the question
Programming language is C++/Visual Studio
Nov 15 '18 #3

weaknessforcats
Expert Mod 5K+
P: 9,197
In this case study up on std::shared_ptr<> and its associates.

Be sure your GDI object ctor/dtor work correctly.

Depending upon whose GDI object you are using,like one written in C, you may need to embed the object in class object so there is ctor/dtor available.
Nov 15 '18 #4

Jurnero
P: 32
Thank you for this clarification. I think it should be very helpful to me.
Nov 16 '18 #5

P: 25
Maybe you need to spend more time studying the theory. Try reading several articles about the memory model in C ++. This will help you understand how memory is allocated.
Also, you can use GDI leak detection tools.
Nov 19 '18 #6

Jurnero
P: 32
Perhaps you `re right. What books, articles do you recommend to reading? What tools do you mean?
Nov 20 '18 #7

P: 23
I can advise such debugger as Deleaker. It works with GDI leaks.
Task Manager can show the presence of such leaks.
Dec 27 '18 #8

Jurnero
P: 32
OldStory, thanks for the answer. I've heard good reviews about this debugger.
Jan 17 '19 #9

Post your reply

Sign in to post your reply or Sign up for a free account.