+ 3
Can we verify deallocation of heap memory for array?
Hello We know that delete and delete[] are used for memory release. Doing just delete on array result into memory leak like p1 in attached code. Can we observe by any means that p1 is only releasing 4 and 4 are missing ? https://code.sololearn.com/cG4s1Nv6COZ8/?ref=app
1 Answer
+ 3
Unfortunately there is no standard way to find out the size of memory a pointer is pointing to ( sizeof (ptr) will always return size of pointer type itself )
Although you can make use of tools like static analyzers and valgrind to find potential leaks in your program.