Sign in Join

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

Mailing lists / fpc-pascal / 2013-03

about "reference-counted" variables

6 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

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

Xiangrong Fang

Is there a "complete" list of reference counted variables in FP? e.g. dynamic arrays are ref-counted. but are variables allocated by New() ref-counted?

My use case is:

type
  PMyRecord = ^TMyRecord;
p: = New(PMyRecord);
MyListView.Item[0].Data = p;
MyListView.Item[0].Delete;     <-- Do I need to Dispose(p) manually when I
remove this item or free the ListView?

Thanks.

Reply by email

Sven Barth
to Xiangrong Fang
"Xiangrong Fang" wrote
Is there a "complete" list of reference counted variables in FP? e.g.

dynamic arrays are ref-counted. but are variables allocated by New() ref-counted?

Dynamic arrays
AnsiString
UnicodeString (and on non Windows also WideString) COM style interfaces (the default interface type)

Regards,
Sven

Reply by email

Marco van de Voort
to Sven Barth

In our previous episode, Sven Barth said:

Show quoted text 8 lines
> Is there a "complete" list of reference counted variables in FP? e.g. dynamic arrays are ref-counted. but are variables allocated by New() ref-counted? Dynamic arrays AnsiString UnicodeString (and on non Windows also WideString) COM style interfaces (the default interface type)

- All of these stored in olevariants.

Also widestrings are not refcounted on the pascal level, but "managed".

Reply by email

Marco van de Voort
to Xiangrong Fang

In our previous episode, Xiangrong Fang said:

> Also widestrings are not refcounted on the pascal level, but "managed". > What's the implication of the difference between refcounted vs. "managed"?

There is a refcount system in the pascal RTL for internal types. Some types are externally managed, and the Pascal runtime merely inserts certain calls for those types, and doesn't know the implementation details exactly itself.

Reply by email