Mesh Generation

The design and the implementation of a computer program performing some task usually requires taking care of various aspects. What is needed is to design the algorithm, to implement and test it and, possibly, to profile it (speed and memory requirements). Optimizing a computer program consists of optimizing its running time and/or its memory requirements, or fine tuning its time-space trade-off. In this section, we briefly review some features any programmer should be familiar with when pursuing these goals (dealing with efficiency and robustness).
Broadly speaking, the memory handling of a computer by the operating system is usually divided into two categories, the static and the dynamic memories. Basically, the static memory is a chunk used in a stack-like manner to store the local variables and the parameters used in the user-defined procedures and functions. The dynamic memory is a pool the user can request slots from in a dynamic fashion.
In Section 2.2, we saw that allocating and de-allocating dynamic memory could be very costly. A good strategy sometimes consists of writing a special case dedicated memory handler using particular features of the requests processed. For example, if one knows beforehand how much space is going to be needed, a linked list or a stack may be better implemented by a static array.
Another problem is fragmentation. If too many small slots are requested and freed too often, the memory map may end up like a piece of gruyere cheese.