[fpc-devel]some memory lost on exception
Jonas Maebe
jonas at zeus.rug.ac.be
Thu Jan 17 16:12:24 CET 2002
On woensdag, januari 16, 2002, at 07:47 , Aleksey V. Vaneev wrote:
> ----
> uses SysUtils;
>
> begin
> raise Exception.createFmt ('error %d', [1]);
> end.
> ----
>
> This small program reports a memory loss when compiling with -glh.
The reason is that you create an object in the raise statement. This
(exception) object is not caught, so the program terminates (without
doing any kind of cleanup).
> In fact this maybe not a problem at all, but if these losses could be
> eliminated that would result in a simpler debugging.
The memory blocks that are left allocated are 1 for the exception
object, one for the ansistring message and one for the exception stack.
I don't think it would be smart to try to deallocate all those things
when the program terminates because of an exception, since the exception
can also be caused by memory corruption or so and in that case trying to
free all memory would cause additional exceptions and would make
debugging even more complex.
> I'm using go32v2 compiler v1.1 snapshot dated 12-jan-2002.
It also happens under 1.0.5.
Jonas
More information about the fpc-devel
mailing list