A
A
anikavoi2018-09-21 10:59:32
C++ / C#
anikavoi, 2018-09-21 10:59:32

How to determine that memory is leaking? How to get the size of the memory occupied by an instance of a class?

Two questions:
1. Is there any regular way to determine that you forgot delete somewhere and the memory is leaking.
2. Is there a way to get the size of the memory that the class instance currently occupies.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vitaly, 2018-09-21
@vt4a2h

Yes, there are: valgrind and analogues.

R
res2001, 2018-09-21
@res2001

1. In addition to the free valgrind, there is also intel vtune that works much faster, but costs money.
2.sizeof(). But it will only return the size of the internal data members of the class. If you additionally allocate dynamic memory in your class, then sizeof will not take this into account. Except you, no one knows how much memory a class eats and how to calculate it correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question