Memory management by interfacing C/C++

Paul Backus snarwin at gmail.com
Sun Apr 28 03:54:17 UTC 2019


On Saturday, 27 April 2019 at 22:25:58 UTC, Ferhat Kurtulmuş 
wrote:
> Hi,
>
> I am wrapping some C++ code for my personal project (opencvd), 
> and I am creating so many array pointers at cpp side and 
> containing them in structs. I want to learn if I am leaking 
> memory like crazy, although I am not facing crashes so far. Is 
> GC of D handling things for me? Here is an example:
>
> [...]
>
> The question is now: what will happen to "int *cintv" which is 
> allocated with new operator in cpp code? I have many code 
> similar in the project, but I have not encounter any problem so 
> far even in looped video processings. Is GC of D doing 
> deallocation automagically?
> https://github.com/aferust/opencvd

D's GC only collects memory allocated with D's `new` operator. 
Memory allocated by C++'s `new` operator must be freed by C++'s 
`delete` operator.


More information about the Digitalmars-d-learn mailing list