6

V does have neither a manual memory release, nor a garbage collector (reference counting) nor an owner-based mechanism like Rust. How does it decide when to free memory?

Thomas S.
  • 5,804
  • 5
  • 37
  • 72

1 Answers1

5

You can manually manage memory in V if you like by calling C.malloc and C.free.

V has experimental support for automatically freeing memory when it is no longer referenced. Use v -autofree, but there may be bugs for now. It allows some borrowing of owned memory when the reference doesn't escape. When it does escape, V will reference count the allocation.

It is influenced by Lobster: https://aardappel.github.io/lobster/memory_management.html