We conducted an expert evaluation of the app for analyzing memory leaks and GDI resource usage
-
Industry
IT
-
Project type
Web
Description
Our client provides its own software solution for pharmacies – a system for the primary management of a work process in independent pharmacies and pharmacy chains. After the migration of the app from Delphi 2007 to Delphi 10.3, there appeared some issues during its intensive usage. Amid user interaction with the app, GDI resources utilized by the software achieve the maximum level of 10000 GDI resources for a process. As a result, the app can’t create additional management elements and it crashes with different error reports. The app can increase the GDI limit up to 65K but it can only postpone the moment of app crash but won’t solve the problem.
The problem doesn’t appear in the Delphi 2007 app version though the code in many parts of both versions is identical. After the migration to Delphi 10.3 one of the key updates was the transformation of String into AnsiString in those places where it was required. It was the most serious change. Another important update was the replacement of some components with their Unicode version.
The client turned to us with a request to conduct the evaluation of the existing code and provide recommendations on the ways to enhance the app and solve the problems.
After the migration of our application from Delphi 2007 to Delphi 10.3 we started noticing problems during its active usage. The GDI resources that are utilized by the app reach the maximum level of 10 000 GDI resources for one process. It leads to abnormal app crashes with different error reports.
Project Team size
- Project Manager
- Business Analyst
- 2 Developers

Solutions
The key goals of these steps were the identification of the basic line for making decisions in the future and the elaboration of potential solutions that could be included in a final document. The goal of introducing this document was to formalize the current code state in one place and describe the existing problems in Delphi code, problems with GDI, memory leaks, as well as conclusions, and results of the Delphi 10.3 app version performance. The information in the document described all the evaluation results and became a basic plan for further steps aimed at solving the considered problems. It included the following points:
- The description of the usage of GDI processors in problematic forms;
- The description of the GDI problem nature and places where such problems appeared;
- The description of problematic forms and blocks;
- The description of the current code state and possible code improvements;
- The list of problematic components that could be improved and changed.
In the process of studying the software, we detected a row of problems that could indicate the necessity of code refactoring and optimization. Some code peculiarities make its maintenance more complicated and make troubleshooting more time-consuming. In some places, the risk of program failure is growing which can be indirectly related to the issues that are being fixed.

Technologies
- Used in the project
-
Delphi
-
VCL
-
CrystalReports
Outcome
- Thanks to our deep app analysis, we’ve identified problematic forms that could lead to leaks, as well as found other code parts that could be improved for increasing the app performance.
- As a result, the client’s team could eliminate the source of the problem and fix the issues that they hadn’t noticed before the app analysis.