Deterministic Memory Management With Standard Library Progress

bachmeier via Digitalmars-d digitalmars-d at puremagic.com
Mon Mar 6 11:52:51 PST 2017


On Monday, 6 March 2017 at 17:54:25 UTC, Anthony wrote:
> Would it be possible/practical to use another language's code 
> within a  D program, like Rust for example, when deterministic 
> memory management is necessary? It feels like this would be 
> easier then finagling with D to get a similar outcome.

Yes. You can call Rust code from C:
https://doc.rust-lang.org/book/ffi.html#calling-rust-code-from-c
You can do the same to call it from D. I have never done it, but 
I did call Rust from Ruby at one point.

> Does the GC run regardless of if it's used? Someone alluded to 
> this earlier, but I just wanted clarity. If I write nogc code, 
> will the GC just stand by idly? Or, is there an option to 
> completely turn it off?

If you don't allocate with the GC, the GC doesn't run. Code 
marked @nogc is guaranteed not to cause the GC to run. You can 
turn the GC off using GC.disable, but there are extreme cases in 
which it can still run.


More information about the Digitalmars-d mailing list