
\section{Memory Management} \label{Memory Management}

LEDA offers an efficient memory management system that is used internally 
for all node, edge and item types. This system can easily be customized for 
user defined classes by the ``LEDA\_MEMORY" macro. You simply have
to add the macro call ``LEDA\_MEMORY($T$)" to the declaration of a class
$T$. This redefines new and delete operators for type $T$, such that
they allocate and deallocate memory using LEDA's internal memory manager. 

{\bf Attention:}
There is a restriction on the size of the type $T$, however. Macro
LEDA\_MEMORY may only be applied to types $T$ with {\bf sizeof(T) \< 256}.
Note that this condition is (for efficiency reasons) not checked. 

We continue the example from section \ref{Overloading}:

\medskip
{\bf struct} $pair$ $\{$\\
\hspace*{.5cm}$double$ $x$;\\
\hspace*{.5cm}$double$ $y$;

\hspace*{.5cm}$pair()$$\{\ x = y = 0;\ \}$\\
\hspace*{.5cm}$pair($const $pair\&\ p)\ \{\ x = p.x;\ y = p.y;\ \}$

\hspace*{.5cm}friend $ostream$\& \ operator\<\<($ostream$\&,const $pair$\&) \hspace{.7cm}$\{$ \dots $\}$\\
\hspace*{.5cm}friend $istream$\& \ operator\>\>($istream$\&,$pair$\&) \hspace{1.85cm}$\{$ \dots $\}$\\
\hspace*{.5cm}friend $int$ \hspace{1.3cm}compare(const $pair\&\ p$, const $pair\&\ q$) $\{$ \dots $\}$

\hspace*{.5cm}LEDA\_MEMORY($pair$)

$\}$;

\smallskip
dictionary\<$pair$,$int$\> D;


 
