What effect does the disable:1 option have on garbage collection? Does it stop garbage collection entirely or just prevent them from running at the start of the program? From this link I can see there are multiple options however, if I wanted to avoid the garbage collector entirely would it be best to just use betterC or do manual memory management as suggested by the blog here which mentions using the c std. library.
Thread overview |
---|
March 14 Configuring the Garbage Collector | ||||
---|---|---|---|---|
| ||||
March 14 Re: Configuring the Garbage Collector | ||||
---|---|---|---|---|
| ||||
Posted in reply to cam-bam | On Friday, 14 March 2025 at 09:14:38 UTC, cam-bam wrote: >What effect does the disable:1 option have on garbage collection? It stops GC from running. Meaning, you can still allocate memory from GC heap and use all functionality that requires GC, but allocations will not trigger garbage collection (you can still run it manually with if I wanted to avoid the garbage collector entirely would it be best to just use betterC or do manual memory management as suggested by the blog BetterC is a subset of D with a reduced feature set. It removes all features that depend on DRuntime: not only GC but also classes, exceptions, RTTI etc. Phobos and D libraries are mostly incompatible with it. It’s meant for cases when you can’t use DRuntime, like if you’re targeting WebAssembly or some microcontroller. Manual memory management doesn’t require disabling GC or writing in BetterC. Garbage collection can only be triggered when you allocate memory from the GC heap. But You can always use the good old Probably, you don’t need to avoid GC in the entirety of your program. You can make the “hot” part of your code |
March 14 Re: Configuring the Garbage Collector | ||||
---|---|---|---|---|
| ||||
Posted in reply to Ogion | On Friday, 14 March 2025 at 14:59:50 UTC, Ogion wrote: >On Friday, 14 March 2025 at 09:14:38 UTC, cam-bam wrote: >What effect does the disable:1 option have on garbage collection? It stops GC from running. Meaning, you can still allocate memory from GC heap and use all functionality that requires GC, but allocations will not trigger garbage collection (you can still run it manually with if I wanted to avoid the garbage collector entirely would it be best to just use betterC or do manual memory management as suggested by the blog BetterC is a subset of D with a reduced feature set. It removes all features that depend on DRuntime: not only GC but also classes, exceptions, RTTI etc. Phobos and D libraries are mostly incompatible with it. It’s meant for cases when you can’t use DRuntime, like if you’re targeting WebAssembly or some microcontroller. Manual memory management doesn’t require disabling GC or writing in BetterC. Garbage collection can only be triggered when you allocate memory from the GC heap. But You can always use the good old Probably, you don’t need to avoid GC in the entirety of your program. You can make the “hot” part of your code Thank you. So just to clarify if I use the disable:1 option and append to an array using the "~=" option this still will not class garbage collection unless I implicitly say GC.collect()? Thats pretty cool. furtrhermore, If I don't call GC.collect() I would assume I would have to sort of free this memory manually without running leaks |