Thread overview
NuMem - safe(r) nogc memory managment
Dec 30, 2023
Luna
Dec 30, 2023
Guillaume Piolat
Dec 30, 2023
ryuukk_
Dec 30, 2023
ryuukk_
Dec 30, 2023
Guillaume Piolat
Dec 31, 2023
IGotD-
Jan 02, 2024
Sergey
Jan 03, 2024
Guillaume Piolat
December 30, 2023

NuMem 0.5.4 has been released, numem is a new library I am developing with contributions from Auburn Sounds/p0nce. It's meant to provide safer ways of writing nogc code, which is sometimes neccesary when the D garbage collector would be an unoptimal choice.

NuMem currently features:

  • C++ style smart pointers (unique_ptr, shared_ptr, weak_ptr)
  • C++ style vector type (with support for moving unique_ptr's in!)
  • Alternative for new and destroy; nogc_new and nogc_delete.
  • A string alternative built on the vector implementation
    • Automatic null-pointer handling, for easy passing of strings to C.
  • A minimal_rt mode meant for environments where only a tiny subset of the D runtime is present, with custom handling of class destruction that doesn't use TypeInfo.
    • Eg. the port of D I'm making for the SEGA Dreamcast.

We plan to add more memory management utilities, thereby making writing completely GC-less D code a lot more user-friendly.

You can find the package here
https://code.dlang.org/packages/numem

Additionally, the yxml package uses numem's smart pointers and strings.
https://code.dlang.org/packages/yxml

December 30, 2023

On Saturday, 30 December 2023 at 15:17:36 UTC, Luna wrote:

>
  • C++ style smart pointers (unique_ptr, shared_ptr, weak_ptr)
  • C++ style vector type (with support for moving unique_ptr's in!)

Indeed with numem you can have a relatively "C++11" experience with scoped ownership, which we intend to make use of because without GC it's easy to be plagued by leaks in user code.

December 30, 2023

Nice, thanks for sharing, it'll be very useful for the C++ developers who want to give D a try

December 30, 2023
>

We plan to add more memory management utilities, thereby making writing completely GC-less D code a lot more user-friendly.

I'd be happy to help

What D really is missing right now, and will hopefully get before phobosv3 is a good and minimalistic Allocator API, i modeled mine around zig's, no RAII, just a simple struct with 3 function ptr

December 30, 2023

On Saturday, 30 December 2023 at 16:36:38 UTC, ryuukk_ wrote:

>

What D really is missing right now, and will hopefully get before phobosv3 is a good and minimalistic Allocator API, i modeled mine around zig's, no RAII, just a simple struct with 3 function ptr

FWIW it's possible to do a generic one with one function pointer:
https://www.lua.org/manual/5.4/manual.html#lua_Alloc

December 31, 2023

On Saturday, 30 December 2023 at 16:36:38 UTC, ryuukk_ wrote:

> >

We plan to add more memory management utilities, thereby making writing completely GC-less D code a lot more user-friendly.

I'd be happy to help

What D really is missing right now, and will hopefully get before phobosv3 is a good and minimalistic Allocator API, i modeled mine around zig's, no RAII, just a simple struct with 3 function ptr

Yes, but first we can replace all the data structures in druntime to use non GC versions. I don't think there are that many of them. The non GC dynamic array would be a good fit here.

January 02, 2024

On Saturday, 30 December 2023 at 15:17:36 UTC, Luna wrote:

>

NuMem 0.5.4 has been released, numem is a new library

Any meaningful comparison with another similar library will be highly appreciated
https://code.dlang.org/packages/automem

January 03, 2024

On Tuesday, 2 January 2024 at 10:30:52 UTC, Sergey wrote:

>

On Saturday, 30 December 2023 at 15:17:36 UTC, Luna wrote:

>

NuMem 0.5.4 has been released, numem is a new library

Any meaningful comparison with another similar library will be highly appreciated
https://code.dlang.org/packages/automem

I'm not familiar with automem, and I'm not numem primary author.
Goals seems very similar and from a cursory reading:

  • automem is much further along on many points such as: attribute forwarding, @nogc, @safe, DIP1000, allocator support, ranges, support for GC roots, and exists since 6 years.

  • numem is designed to allow C++ programmers to feel at ease, with a bit less runtime use maybe. Containers own their elements, like C++ containers (not sure how it is in automem). We plan a std::map-like.