Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2002-01

some memory lost on exception

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Aleksey V. Vaneev

Hello,

----
uses SysUtils;
begin
    raise Exception.createFmt ('error %d', [1]);
end.
----

This small program reports a memory loss when compiling with -glh. In fact this maybe not a problem at all, but if these losses could be eliminated that would result in a simpler debugging.

I'm using go32v2 compiler v1.1 snapshot dated 12-jan-2002.

Best regards,
Aleksey

Reply by email

Jonas Maebe
to Aleksey V. Vaneev
Aleksey V. Vaneev wrote 9 lines
---- 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

Reply by email