Book Image

Mastering Delphi Programming: A Complete Reference Guide

By : Primož Gabrijelčič
Book Image

Mastering Delphi Programming: A Complete Reference Guide

By: Primož Gabrijelčič

Overview of this book

Delphi is a cross-platform Integrated Development Environment (IDE) that supports rapid application development for most operating systems, including Microsoft Windows, iOS, and now Linux with RAD Studio 10.2. If you know how to use the features of Delphi, you can easily create scalable applications in no time. This Learning Path begins by explaining how to find performance bottlenecks and apply the correct algorithm to fix them. You'll brush up on tricks, techniques, and best practices to solve common design and architectural challenges. Then, you'll see how to leverage external libraries to write better-performing programs. You'll also learn about the eight most important patterns that'll enable you to develop and improve the interface between items and harmonize shared memories within threads. As you progress, you'll also delve into improving the performance of your code and mastering cross-platform RTL improvements. By the end of this Learning Path, you'll be able to address common design problems and feel confident while building scalable projects. This Learning Path includes content from the following Packt products: Delphi High Performance by Primož Gabrijel?i? Hands-On Design Patterns with Delphi by Primož Gabrijel?i?
Table of Contents (19 chapters)

Memory allocation in a parallel world

We've seen how FastMM boosts the reallocation speed. Let's take a look at another optimization which helps a lot when you write a multithreaded code—as we will in the next three chapters.

The life of a memory manager is simple when there is only one thread of execution inside a program. When the memory manager is dealing out the memory, it can be perfectly safe in the knowledge that nothing can interrupt it in this work.

When we deal with parallel processing, however, multiple paths of execution simultaneously execute the same program and work on the same data. (We call them threads and I'll explain them in the next chapter.) Because of that, life from the memory manager's perspective suddenly becomes very dangerous.

For example, let's assume that one thread wants some memory. The memory manager finds a free...