Why same pointer type for GC and manual memory?

kinke noone at nowhere.com
Thu Nov 14 16:57:54 UTC 2019


On Thursday, 14 November 2019 at 01:08:58 UTC, Suleyman wrote:
> On Wednesday, 13 November 2019 at 16:43:27 UTC, IGotD- wrote:
>> Best example is probably managed C++, an MS extension to C++ 
>> which is now deprecated.
>
> MS Managed C++ was superseded by C++/CLI[1] which was 
> standardized. They actually retained the special syntax for GC 
> pointers.
> One of the motivations if I understand correctly is to let the 
> programmers easily distinguish which pointers should be freed 
> and which ones are managed by the GC. It's not a bad idea when 
> there is extensive use of both manual memory management and 
> garbage collection.

IIRC (it's been a while), a mandatory reason for that distinction 
is that the .NET GC may move managed objects in memory 
(compaction) and so you have to pin them first to get a stable 
pointer.


More information about the Digitalmars-d-learn mailing list