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

GDI Leaks Detection

Jurnero
P: 30
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
4 Weeks Ago #1
Share this Question
Share on Google+
6 Replies


weaknessforcats
Expert Mod 5K+
P: 9,196
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.
4 Weeks Ago #2

Jurnero
P: 30
Thanks for the answer.
Added details to the question
Programming language is C++/Visual Studio
4 Weeks Ago #3

weaknessforcats
Expert Mod 5K+
P: 9,196
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.
4 Weeks Ago #4

Jurnero
P: 30
Thank you for this clarification. I think it should be very helpful to me.
4 Weeks Ago #5

P: 23
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.
3 Weeks Ago #6

Jurnero
P: 30
Perhaps you `re right. What books, articles do you recommend to reading? What tools do you mean?
3 Weeks Ago #7

Post your reply

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