Report a bug
If you spot a problem with this page, click here to create a Bugzilla 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 using
a local clone.
rt.lifetime
This module contains all functions related to an object's lifetime:
allocation, resizing, deallocation, and finalization.
License:
Distributed under the
Boost Software License 1.0.
(See accompanying file LICENSE)
Authors:
Walter Bright, Sean Kelly, Steven Schveighoffer
Source rt/lifetime.d
- void*
_d_allocmemory(size_tsz); - Allocate memory using the garbage collectorDMD uses this to allocate closures:
void f(byte[24] x) { return () => x; // `x` is on stack, must be moved to heap to keep it alive }
Parameters:size_t sznumber of bytes to allocate Returns:pointer toszbytes of free, uninitialized memory, managed by the GC. - Object
_d_newclass(const ClassInfoci); - Create a new class instance.Allocates memory and sets fields to their initial value, but does not call a constructor.
new Object() // _d_newclass(typeid(Object))
Parameters:ClassInfo ciTypeInfo_Class object, to provide instance size and initial bytes to copy Returns:newly created object - void
_d_delinterface(void**p); - void
_d_delclass(Object*p); - pure nothrow void[]
_d_newarrayU(scope const TypeInfoti, size_tlength);
pure nothrow void[]_d_newarrayT(const TypeInfoti, size_tlength);
pure nothrow void[]_d_newarrayiT(const TypeInfoti, size_tlength); - Allocate an array with the garbage collector.Has three variants:
_d_newarrayUleave elements uninitialized_d_newarrayTinitializes to 0 (e.g new int[])_d_newarrayiTinitializes based on initializer retrieved from TypeInfo (e.g new float[])
Parameters:TypeInfo tithe type of the resulting array, (may also be the corresponding array.ptr type) size_t length. lengthof resulting arrayReturns:newly allocated array - pure nothrow void*
_d_newitemU(scope const TypeInfo_ti); - Non-template version of core.lifetime.d_newitemT that does not perform initialization. Needed for rt.aaA.allocEntry.Parameters:
TypeInfo _tiTypeInfo of item to allocate Returns:newly allocated item - void
_d_delmemory(void**p); - void
_d_callinterfacefinalizer(void*p); - void
_d_callfinalizer(void*p); - void
rt_setCollectHandler(CollectHandlerh); - CollectHandler
rt_getCollectHandler(); - nothrow int
rt_hasFinalizerInSegment(void*p, size_tsize, TypeInfotypeInfo, scope const(void)[]segment); - nothrow void
rt_finalize2(void*p, booldet= true, boolresetMemory= true); - nothrow void
rt_finalize(void*p, booldet= true); - Backwards compatibility
- void[]
_d_arrayappendcd(ref byte[]x, dcharc); - Append dchar to char[], converting UTF-32 to UTF-8
void main() { char[] s; s ~= 'α'; }
Parameters:byte[] xarray to append to cast to byte[]. Will be modified. dchar cdchar to append Returns:updatedxcast to void[] - void[]
_d_arrayappendwd(ref byte[]x, dcharc); - Append dchar to wchar[], converting UTF-32 to UTF-16
void main() { dchar x; wchar[] s; s ~= 'α'; }
Parameters:byte[] xarray to append to cast to byte[]. Will be modified. dchar cdchar to append Returns:updatedxcast to void[]
Copyright © 1999-2026 by the D Language Foundation | Page generated by
Ddoc on Thu Jan 15 22:40:50 2026