Re: How to allocate new class instance on the heap?




<chrisspencer02@xxxxxxxxx> wrote in message
news:1117066027.187310.219810@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> Are you saying that
>
> ClassInstanceVariable := tClassName.Create {};
>
> will allocate ClassInstanceVariable on the heap? And it will not be
> automatically deallocated when the function declaring
> ClassInstanceVariable exits? OK, thank you.

No, I was just telling you how you have to go about creating a class
instance. Being the nice guy that I am ;), I also indicated how one could
retain a reference to the instance data.

tClassName.Create creates a new instance and returns a reference to the
location of the new instance's data. Instance data is always stored on the
heap.

Read the Object Pascal (Delphi) Language Reference section of the help (see
table of contents). It does a very good job of explaining the language and
how it works.


.



Relevant Pages

  • Re: Garbage collectable pinned arrays!
    ... reference to it anywhere on the call stack. ... But collecting the object and ... When the array is pinned it is copied to heap. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Abstract class variables question
    ... value can be anything (bool, int, string, etc). ... the heap and _objCurrent is just a pointer to that location. ... reference types, which means that all classes are allocated from the heap. ... As far as boxing and the heap go, I assumed it was a pointer to the heap ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Boxing and Unboxing ??
    ... They are on the heap to avoid lifetime issues. ... int *retrieve ... instead of passed by reference. ... overhead, merely boxing initialization. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: how java variables are stored?
    ... The reference to a local array can go on the ... >> stack but the array object itself goes on the heap. ... In the case of how the Java memory/variable/storage model works, ...
    (comp.lang.java.programmer)
  • Re: Abstract class variables question
    ... I think I understand boxing a little better now. ... the object that is on the heap. ... value types are copied to the heap and made into an object and reference ... String types are already reference types and all we are doing when we do ...
    (microsoft.public.dotnet.languages.csharp)