The code below should work but I get an AV when the program calls
`Bar.Free`.
Do you know why?
Lazarus 1.8.1 r57299 FPC 3.0.4 i386-win32-win32/win64
===begin===
program Project1;
uses
SysUtils;
type
IBar = interface
['{C22FB8F4-1EC6-42C4-81E4-F2A52CC52258}']
function Name: string;
Hi,
Bar shoud be released by Interface, no need to call Free.
V.
__
Od: "Marcos Douglas B. Santos"
Komu: FPC-Pascal users discussions
Datum: 11.03.2018 14:23
Předmět: [fpc-pascal] Using Supports() I got an AV... bug?
The code belo
On Sun, Mar 11, 2018 at 10:52 AM, Vojtěch Čihák wrote:
>
> Hi,
>
> Bar shoud be released by Interface, no need to call Free.
I'm sorry, but `Bar` was defined as `Bar: TBar` so, it's a class not
an interface.
Marcos Douglas
___
fpc-pascal maillist - f
Yes, TBar is TInterfacedObject and is reference counted therefore Free is not
needed.
Just comment the line //Bar.Free; compile with -gh and you will see no memory
leak.
V.
__
Od: "Marcos Douglas B. Santos"
Komu: FPC-Pascal users di
On Sun, Mar 11, 2018 at 11:17 AM, Vojtěch Čihák wrote:
> Yes, TBar is TInterfacedObject and is reference counted therefore Free is
> not needed.
>
> Just comment the line //Bar.Free; compile with -gh and you will see no
> memory leak.
You think this is the problem...
All right, try to change your
With this modification and -gh it is alright:
[v1@nb-msi Interface]$ ./test
Bar supports...
Heap dump by heaptrc unit
7 memory blocks allocated : 875/880
7 memory blocks freed : 875/880
0 unfreed memory blocks : 0
True heap size : 360448
True free heap : 360448
[v1@nb-msi Interface]$
V.
__
Not here. I'm using FPC 3.0.4.
I've took a look at EMB documentation:
http://docwiki.embarcadero.com/Libraries/XE2/en/System.SysUtils.Supports
Take a look at "Warning" section. That's the problem.
Marcos Douglas
___
fpc-pascal maillist - fpc-pascal@lis
On Sun, Mar 11, 2018 at 11:51 AM, Vojtěch Čihák wrote:
> With this modification and -gh it is alright:
>
Only if you declare `Bar` as `IBar` instead of `TBar`. Please, check
your code again.
Regards,
Marcos Douglas
___
fpc-pascal maillist - fpc-pasca
I only added {$mode objfpc} to be able compile, so I test this code:
program Project1;
{$mode objfpc}
uses
SysUtils;
type
IBar = interface
['{C22FB8F4-1EC6-42C4-81E4-F2A52CC52258}']
function Name: string;
end;
TBar = class(TInterfacedObject, IBar)
public
function Name: