开发者

What are managed types? Are they specific to Delphi? Are they specific to Windows?

开发者 https://www.devze.com 2023-02-18 03:36 出处:网络
Summarization: Please check the knowledgeable comments below. ================================开发者_运维百科==============================

Summarization:

Please check the knowledgeable comments below.

================================开发者_运维百科==============================

I have seen the term of managed types mentioned in quite a few stackoverflow Delphi topics. For example, it is mentioned in topics of correctly initializing/finalizing. However, when I google managed types, it seems most links are related to C++, or .NET. For example, see the MSDN page. Could some one help to comment what are managed types defined in Delphi? Given that Delphi for POSIX/MacOS is being born, are managed types specific to Windows? Thanks for your effort and time in advance!

PS: Topics of correctly initializing/finalizing:

Which variables are initialized when in Delphi?

Are delphi variables initialized with a value by default?

How should I free an array of objects in a Delphi 7 destructor?

In Delphi 2009 do I need to free variant arrays?


In the context of Delphi, managed types are those types for whom the Delphi Compiler automatically generates lifecycle management code. This includes:

  • Strings
  • Open Dynamic Arrays
  • Records containing other managed types
  • Interfaces
  • (later edit) Anonymous methods
  • (later edit) Variants

Because managed types in the Delphi context are defined in terms of what the Delphi compiler generates, they're delphi-specific.


In the .NET world the developer doesn't need to manage the lifecycle of allocated memory because .NET provides an automatic mechanism for doing this: The Garbage Collector. But .NET includes the ability to work with things outside the CLR (example: using native DLL's that don't target the CLR). That code is usually called unamanged and unsafe.

In the context of .NET managed relates to what the CLR automatically manages, so that's .NET specific term!


See Barry Kelly's answer to a releated thread. Since managed types are a language feature there shouldn't be significant changes on Mac OS et al.

0

精彩评论

暂无评论...
验证码 换一张
取 消