Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to obtain the names of custom-made structures whose instances have leaked memory?

Tags:

I am working a on parser which will go through a FASTMM4 memory leak report and store all relevant data in a custom-made structure/class. I use VirtualTreeView to display each class that has leaked instances as a node in the tree. The tree - Notice that the FIRST node says unknown. This is because FASTMM calls a method AClass to determine weather it is a class or not. When it finds custom structures, it marks them as unknown, which doesn't make my report analyzer very effective since most memory leaks come from these custom structures and records.

Question: Is there a way to use DebugInfo or some other tool like JVCL to gather those debug symbols and compare their memory addresses to the ones found in the memory-leak-report-file? I would like my tree to stop showing UNKNOWN and show the names of these custom structures. I am new to Delphi programming, and even newer to tackling memory leaks, so any help would mean much!

like image 523
programstinator Avatar asked Sep 21 '12 23:09

programstinator


People also ask

How do you find memory leak source?

To find a memory leak, you've got to look at the system's RAM usage. This can be accomplished in Windows by using the Resource Monitor. In Windows 11/10/8.1: Press Windows+R to open the Run dialog; enter "resmon" and click OK.

How do I find a memory leak in Delphi?

All that it takes to start working with it is add a single line in your project: ReportMemoryLeaksOnShutdown := True; And voilà, your application will report all memory leaks when it shuts down. If there are leaks at the end of your application, a dialog will be displayed showing all the leaks.

What is memory leak in data structure?

In computer science, a memory leak is a type of resource leak that occurs when a computer program incorrectly manages memory allocations in such a way that memory which is no longer needed is not released. A memory leak may also happen when an object is stored in memory but cannot be accessed by the running code.

What is a memory leak give an example how it can be avoided?

The memory leak occurs, when a piece of memory which was previously allocated by the programmer. Then it is not deallocated properly by programmer. That memory is no longer in use by the program. So that place is reserved for no reason. That's why this is called the memory leak.


1 Answers

Maybe extended RTTI (Delphi 2010 an newer) can be used to create a type dictionary, which only holds typeinfo pointers and names of all "non-class" types.

This feature could be enabled with a conditional define to avoid its overhead in normal operation.

like image 83
mjn Avatar answered Dec 18 '22 03:12

mjn