I just installed Delphi 10.2 Release 1. When I recompiled my applications and ran them, I get a lot of memory leaks. I had no memory leaks with 10.2 (without the update). I made no changes to the code either.
To verify, I created a simple blank application and put a few components on the form. No code. Ran the application and got memory leaks reported.
I wanted to highlight this (if only as a warning before you upgrade).
My questions:
Note: I have logged an issue on quality portal, just in case this is a real issue: https://quality.embarcadero.com/browse/RSP-18774. In this ticket I have also attached the sample app.
Memory leak occurs when programmers create a memory in heap and forget to delete it. The consequences of memory leak is that it reduces the performance of the computer by reducing the amount of available memory.
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.
Use reference objects to avoid memory leaks ref package, you can work with the garbage collector in your program. This allows you to avoid directly referencing objects and use special reference objects that the garbage collector easily clears. The special subclasses allow you to refer to objects indirectly.
Memory leaks occur when new memory is allocated dynamically and never deallocated. In C programs, new memory is allocated by the malloc or calloc functions, and deallocated by the free function.
After some investigation I found out that the callbacks being passed to TThread.CurrentThread.ForceQueue
in TStyledControl.KillResourceLink
are never executed because before any thread can handle them the application is ending and the TThread
class destructor is destroying the list that still has unhandled callbacks.
I solved this by adding a call to CheckSynchronize
at the end of FMX.Forms.DoneApplication
which forces the callbacks to be executed which resolved the huge memory leak.
I don't know if this is the correct fix for the issue but it solved the memory leaks being reported.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With