delphi - Why TObject.Free is called before the first line of code of my application is executed? -


We are trying to find out if our software has memory leaks or not. Therefore, it is possible that I am using various tools and programs to help in finding potential memory leaks. One of the software I used was AQTime since it came with Delphi XE, it was just a demo, so I was not really able to get any useful information about it. Then, I decided to use free software, MemProof so far, it has shown me many issues with our software which needs attention. One of which is the error.

As soon as I start my program through MemProof, it lists 2 errors, which is trying to destroy the non-existent object from the unit file, system.pas. So, when I actually put a break point inside the toubt. The free process, my program broke it all the way before it started. While stepping through the Free Process in System.pas, I came to know that TiConimage is trying to destroy or free itself. In other words, before actually starting, within my program the free process Is not implemented.

Here is the real free process:

  process TObject.Free; Get started if you & lt; & Gt; Nile then destroyed; End;   

After that observation, I removed the breakpoint and ran the program in every way. The user got ready for input in the main window of my program, however, I also learned that Toubys Non-stop is applied to the free process if any part of the window of my program is displayed on the screen. I do not understand why this is so? Can anyone explain? How TForm is related to TObject. Is TForm displayed when the process in any size or form is continually displayed on the screen?

Thanks in advance.

Why does TObject.Free execute a lot, Is destroyed, any object, that method can be called. All classes are received from the tubettes, it is a common ancestor, so in nearly any action in the Delphi program, a large number of objects will be created / destroyed pairs and as a result, TObject.Free will be hit.

Regarding detection of memory leaks, you have been created in Delphi to fix this. FastMM Memory Manager can be run in the "Report Memory Leak" mode and it will give you the weight of the diagnostics of any memory.

Consider the following trivial programs:

  Program leak; Starting ReportMemory Lexon Shutdown: = True; TObject.Create; End.   

This results in the following output:

Enter Image Description Here

You just need to set ReportMemoryLeaksOnShutdown anywhere in your app (the start of the .dpr file is in the form of a good place in any form).

If you want to get more information in the report, you can download it and configure your heart's content.

Then you can get the output like this:

  A memory block is leaked Size: 84 This block thread was allocated by 0x1304, and that Time Stack Trace (Returns) was: 40455 E [Systems] [Systems. GetMem] 405 A2F [Systems] [SystemTabage. New humankind] 40602 e [system] [system. @ ClassCreate] 4474C2 [class] [Classes.tstringList.Create] C275A3 [Main.pas] [Main] [Main.TMainForm.CreateAuxiliaryForms] [997] C84C8A [OrcaFlex.dpr] [OrcaFlex] [OrcaFlex.OrcaFlex] [ 351] 75E633CA [BaseThreadInitThunk] 77519ED2 [Function on unknown RtlInitializeExceptionChain] 77519EA5 [Unknown Function on RtlInitializeExceptionChain] Block is currently used for a purpose of class: TStringList   

This is really amazing is. It tells me that the leaking memory was allocated in the Main.pas line 997, and where I made my intentionally leaked that's fine!

Comments