View source code
Display the source code in std/experimental/allocator/gc_allocator.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aGitHub issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.
Struct std.experimental.allocator.gc_allocator.GCHeapMallocator
Allocates from the D runtime's garbage-collected heap, but frees memory
manually using GC rather than leaving it for the GC to
collect.
struct GCHeapMallocator;
Fields
| Name | Type | Description |
|---|---|---|
instance
|
const(shared(GCHeapMallocator)) | Returns the global instance of this allocator type. The garbage-collected
allocator is thread-safe, therefore all of its methods and instance itself
are shared.
|
Methods
| Name | Description |
|---|---|
allocate
(bytes)
|
Standard allocator methods per the semantics defined above. The deallocate and reallocate methods are @system because they may
move memory around, leaving dangling pointers in user code.
|
deallocate
(b)
|
Standard allocator methods per the semantics defined above. The deallocate and reallocate methods are @system because they may
move memory around, leaving dangling pointers in user code.
|
expand
(b, delta)
|
Standard allocator methods per the semantics defined above. The deallocate and reallocate methods are @system because they may
move memory around, leaving dangling pointers in user code.
|
goodAllocSize
(n)
|
Standard allocator methods per the semantics defined above. The deallocate and reallocate methods are @system because they may
move memory around, leaving dangling pointers in user code.
|
reallocate
(b, newSize)
|
Standard allocator methods per the semantics defined above. The deallocate and reallocate methods are @system because they may
move memory around, leaving dangling pointers in user code.
|
resolveInternalPointer
(p, result)
|
Standard allocator methods per the semantics defined above. The deallocate and reallocate methods are @system because they may
move memory around, leaving dangling pointers in user code.
|
Example
auto buffer = GCHeapMallocator .instance .allocate(1024 * 1024 * 4);
scope(exit) GCHeapMallocator .instance .deallocate(buffer);
Authors
License
Copyright © 1999-2026 by the D Language Foundation | Page generated by ddox.