[Off-Topic] John Carmack's point of view on GC and languages like JavaScript
Paul Backus
snarwin at gmail.com
Mon Aug 8 15:25:40 UTC 2022
On Monday, 8 August 2022 at 15:05:49 UTC, wjoe wrote:
> ```
> @GC(DND)//Do Not Disturb
> {
> foreach (...)
> // hot code goes here and no collection cycles will happen
> }
> ```
> or,
> ```
> void load_assets()
> {
> // allocate, load stuff, etc..
> @GC(collect); // lag doesn't matter here
> }
> ```
This is possible using the `GC` API in `core.memory`:
```d
{
import core.memory: GC;
GC.disable();
scope(exit) GC.enable();
foreach (...)
// hot code goes here
}
```
```d
void load_assets()
{
import core.memory: GC;
// allocate, load stuff, etc..
GC.collect();
}
```
More information about the Digitalmars-d
mailing list