Thread overview | ||||||
---|---|---|---|---|---|---|
|
May 16, 2013 Garbage collector question | ||||
---|---|---|---|---|
| ||||
Does the garbage collector manages the memory from extern(C) functions, or we have to delete manualy the objects created in those kind of functions? Thanks, Bogdan |
May 16, 2013 Re: Garbage collector question | ||||
---|---|---|---|---|
| ||||
Posted in reply to gedaiu | On Thursday, 16 May 2013 at 06:08:30 UTC, gedaiu wrote:
> Does the garbage collector manages the memory from extern(C) functions, or we have to delete manualy the objects created in those kind of functions?
>
> Thanks,
> Bogdan
You mean something like malloc or any kind of, for example, derelict functions?
If so: You have to delete manually.
Or did you mean regular functions in D which are denoted with extern (C)?
If so: extern (C) means only C linkage behaviour.
So as long as you do not use some C functions, like malloc, you don't have to delete your memory manually in this case.
Otherwise I've misunderstood your question.
|
May 16, 2013 Re: Garbage collector question | ||||
---|---|---|---|---|
| ||||
Posted in reply to gedaiu | On Thursday, May 16, 2013 08:08:28 gedaiu wrote:
> Does the garbage collector manages the memory from extern(C) functions, or we have to delete manualy the objects created in those kind of functions?
The GC managase memory allocated with new or with core.memory. That's it. Anything allocated with normal malloc or anything else must be managed according to how that memory allocator works (which in the case of malloc, would mean calling free to deallocate the memory).
- Jonathan M Davis
|
May 16, 2013 Re: Garbage collector question | ||||
---|---|---|---|---|
| ||||
Posted in reply to Namespace | On Thursday, 16 May 2013 at 06:21:06 UTC, Namespace wrote:
> On Thursday, 16 May 2013 at 06:08:30 UTC, gedaiu wrote:
>> Does the garbage collector manages the memory from extern(C) functions, or we have to delete manualy the objects created in those kind of functions?
>>
>> Thanks,
>> Bogdan
>
> You mean something like malloc or any kind of, for example, derelict functions?
> If so: You have to delete manually.
>
> Or did you mean regular functions in D which are denoted with extern (C)?
> If so: extern (C) means only C linkage behaviour.
> So as long as you do not use some C functions, like malloc, you don't have to delete your memory manually in this case.
>
> Otherwise I've misunderstood your question.
Thanks,
That was the answer that i was looking for... i thought that if i use extern(C) the compiler it's acting like a c compiler or something like that..
But it's good to know that every object that I create with new it will be "watched" bu GC.
Bogdan
|
Copyright © 1999-2021 by the D Language Foundation