The V Programming Language | 您所在的位置:网站首页 › nim中文 › The V Programming Language |
Flexible memory management
V avoids doing unnecessary allocations in the first place by using value types, string buffers, promoting a simple abstraction-free code style. There are 4 ways to manage memory in V. The default is a minimal and a well performing tracing GC. The second way is autofree, it can be enabled with -autofree. It takes care of most objects (~90-100%): the compiler inserts necessary free calls automatically during compilation. Remaining small percentage of objects is freed via GC. The developer doesn't need to change anything in their code. "It just works", like in Python, Go, or Java, except there's no heavy GC tracing everything or expensive RC for each object. For developers willing to have more low level control, memory can be managed manually with -gc none. Arena allocation is available via v -prealloc. V's autofree demo. All objects are freed during compilation. Running the Ved editor on an 8 MB file with 0 leaks: |
CopyRight 2018-2019 实验室设备网 版权所有 |