Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
github.com/smasher164/mem
Package mem implements a memory allocator and deallocator. It currently uses mmap on unix and VirtualAlloc on windows to request pages of memory from the operating system, and munmap and VirtualFree to release pages of memory to the operating system. The allocator uses a first-fit algorithm on a singly-linked free list of blocks. Blocks are divided into sets called arenas, which correspond to the chunk of memory mapped from the operating system. When all of the blocks in a set are freed, the arena is unmapped.
// Alloc allocates size bytes of memory, and returns a pointer to it.
// It is goroutine-safe and attempts to preserve the semantics of
// POSIX libc's malloc. However, Alloc panics if an error occurs when
// requesting more memory from the operating system.
func Alloc(size uint) unsafe.Pointer
// Free deallocates the memory pointed to by p. It is goroutine-safe
// and attempts to preserve the semantics of POSIX libc's free.
// However, Free panics if an error occurs when releasing memory to
// the operating system.
func Free(p unsafe.Pointer)
I am working on a rudimentary language interpreter for which I want to implement my own garbage collection algorithm in Go. Also, this is a good opportunity for me to brush up on memory allocation techniques.
If you want to? ¯\_(ツ)_/¯ It's passed all the tests I've run so far. But don't hold me liable if your multi-million dollar production workload comes crashing down! Instead, file an issue. :)
Why thank you for offering! I am really interested in exploring more efficient memory allocation techniques, like using a best-fit algorithm, using a doubly-linked list for constant-time cleanup, segregated lists to divide allocations of different size classes, and buddy allocation. I would also like to improve test quality by testing edge cases and platform-specific eccentricities.
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.