Hi all,
I am planning to write some D code without GC. But I have no prior experience with it. I have experience using manual memory management languages. But D has so far been used with GC. So I want to know what pitfalls it has and what things I should watch out for. Also, I want to know what high level features I will be missing.
Thanks in advance.
Thread overview | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
June 11 How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
June 11 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vinod K Chandran | On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote: > ... Similar posts that may help: https://forum.dlang.org/thread/hryadrwplyezihwagiox@forum.dlang.org https://forum.dlang.org/thread/dblfikgnzqfmmglwdxdg@forum.dlang.org Matheus. |
June 11 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to matheus | On Tuesday, 11 June 2024 at 13:35:19 UTC, matheus wrote:
> On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote:
>> ...
>
> Similar posts that may help:
>
> https://forum.dlang.org/thread/hryadrwplyezihwagiox@forum.dlang.org
>
> https://forum.dlang.org/thread/dblfikgnzqfmmglwdxdg@forum.dlang.org
>
> Matheus.
Thank you Matheus, let me check that. :)
|
June 11 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vinod K Chandran |
|
June 11 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On Tuesday, 11 June 2024 at 14:59:24 UTC, Kagamin wrote: >
Oh thank you @Kagamin. That's some valuable comments. I will take special care. |
June 11 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Kagamin | On 11.06.2024 17:59, Kagamin wrote: > 1) arena allocator makes memory manageable with occasional cache invalidation problem > 2) no hashtable no problem [OT] could you elaborate what problems they cause? > 3) error handling depends on your code complexity, but even in complex C# code I found exceptions as boolean: you either have an exception or you don't > 4) I occasionally use CTFE, where `@nogc` is a nuisance > 5) polymorphism can be a little quirky |
June 11 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vinod K Chandran | On Tuesday, 11 June 2024 at 13:00:50 UTC, Vinod K Chandran wrote: >Hi all, I could answer the question directly, but it seems others have already done so. I would instead ask the reason for wanting to write D code without the GC. In many cases, you can write code without regularly using the GC (i.e. preallocate, or reuse buffers), but still use the GC in the sense that it is there as your allocator. A great example is exceptions. Something that has the code So I would call this kind of style writing code that avoids creating garbage. To me, this is the most productive way to minimize GC usage, while still allowing one to use D as it was intended. -Steve |
June 11 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer wrote: >I would instead ask the reason for wanting to write D code without the GC. -Steve Hi Steve,
|
June 12 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vinod K Chandran | On Tuesday, 11 June 2024 at 17:15:07 UTC, Vinod K Chandran wrote: >On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer wrote: >I would instead ask the reason for wanting to write D code without the GC. -Steve Hi Steve,
rather then worring about the gc, just have 95% of data on the stack |
June 12 Re: How to use D without the GC ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vinod K Chandran | On Tuesday, 11 June 2024 at 17:15:07 UTC, Vinod K Chandran wrote: >On Tuesday, 11 June 2024 at 16:54:44 UTC, Steven Schveighoffer wrote: >I would instead ask the reason for wanting to write D code without the GC. -Steve Hi Steve,
the GC only runs on allocation. if you want to squeeze out the last bit of performance, you should preallocate all bufferes anyway, and GC vs no GC doesn't matter. |