Lines Matching refs:GC

13    $(LI The GC is a conservative mark-and-sweep collector. It only runs a
16 there will be no GC collection pauses. The pauses occur because
17 all threads the GC knows about are halted so the threads' stacks
18 and registers can be scanned for references to GC allocated data.
21 $(LI The GC does not know about threads that were created by directly calling
24 Such threads will not be paused for a GC collection, and the GC might not detect
25 references to GC allocated data held by them. This can cause memory corruption.
28 $(LI Do not hold references to GC allocated data in such threads.)
32 GC does know about.)
33 $(LI Disable GC collection cycles while that thread is active with $(LREF disable)/$(LREF enable).)
34 $(LI Register the thread with the GC using $(REF thread_attachThis, core,thread)/$(REF thread_detachThis, core,thread).)
49 * the $(D GC.$(LREF addRange)) function are always scanned conservatively.
51 * it will still be scanned for possible GC pointers. And, if the
52 * word-interpreted representation of the variable matches a GC-managed
57 * relevant when scanning the heap. Thus, casting a GC pointer to an
59 * type inside the GC heap may mean that it will not be recognized
61 * the $(D GC.BlkAttr.$(LREF NO_SCAN)) attribute.)
72 * so long as no valid GC pointers are invalidated in the process.
73 * However, _memory allocated with $(D GC.BlkAttr.$(LREF NO_MOVE)) must
77 * only reference to a GC-managed _memory block points into the
79 * GC must consider the _memory block live. The exception to this
81 * $(D GC.BlkAttr.$(LREF NO_INTERIOR)) attribute; it is the user's
86 * pointer values and GC-managed _memory blocks, so long as such a
90 * $(LI Implementations are free to assume that GC pointers are only
136 extern (C) GC.Stats gc_stats ( ) @safe nothrow @nogc;
137 extern (C) GC.ProfileStats gc_profileStats ( ) nothrow @nogc @safe;
230 struct GC
235 * Aggregation of GC stats to be exposed via public API
239 /// number of used bytes on the GC heap (might only get updated after a collection)
241 /// number of free bytes on the GC heap (might only get updated after a collection)
253 /// total number of GC cycles
255 /// total time spent doing GC
257 /// total time threads were paused doing GC
259 /// largest time threads were paused during one GC cycle
261 /// largest time spent doing one GC cycle
325 int* pToArray = cast(int*)GC.malloc(10 * int.sizeof, GC.BlkAttr.NO_SCAN | GC.BlkAttr.APPENDABLE);
452 * ti = TypeInfo to describe the memory. The GC might use this information
478 * ti = TypeInfo to describe the memory. The GC might use this information
506 * ti = TypeInfo to describe the memory. The GC might use this information
530 * If `p` is pointing to memory not allocated from the GC or to the interior
554 * ti = TypeInfo to describe the memory. The GC might use this information
559 * zero or the pointer does not point to the base of an GC allocated
578 auto data1 = cast(ubyte*)GC.calloc(size1);
579 auto data2 = cast(ubyte*)GC.realloc(data1, size2);
581 GC.BlkInfo info = GC.query(data2);
597 * ti = TypeInfo to describe the full memory block. The GC might use
621 int* p = cast(int*)GC.malloc(size * int.sizeof, GC.BlkAttr.NO_SCAN);
624 size_t u = GC.extend(p, 1000 * int.sizeof, 2000 * int.sizeof);
638 size_t u = GC.extend(p, 1000 * int.sizeof, 2000 * int.sizeof);
667 * set. If finalization is desired, call $(REF1 destroy, object) prior to `GC.free`.
731 size_t size = GC.sizeOf(data);
733 data = cast(int*)GC.realloc(data, 4100);
734 size = GC.sizeOf(data);
766 * Returns runtime stats for currently active GC implementation
767 * See `core.memory.GC.Stats` for list of available metrics.
775 * Returns runtime profile stats for currently active GC implementation
776 * See `core.memory.GC.ProfileStats` for list of available metrics.
786 * Adds an internal root pointing to the GC memory block referenced by p.
793 * p = A pointer into a GC-managed memory block or null.
802 * // Allocate an object on the GC heap (this would usually be
807 * // longer referenced from D code (stack, GC heap, ���).
808 * GC.addRoot(cast(void*)context);
812 * GC.setAttr(cast(void*)context, GC.BlkAttr.NO_MOVE);
820 * // added root can be removed again now to allow the GC
822 * GC.removeRoot(ctx);
823 * GC.clrAttr(ctx, GC.BlkAttr.NO_MOVE);
839 * p = A pointer into a GC-managed memory block or null.
850 * GC-managed memory block, addRange does $(I not) mark this block as live.
856 * ti = TypeInfo to describe the memory. The GC might use this information
865 * // Add it as a GC range.
866 * GC.addRange(rawMemory, size);
868 * // Now, pointers to GC-managed memory stored in
901 * Queries the GC whether the current thread is running object finalization
902 * as part of a GC collection, or an explicit call to runFinalizers.
904 * As some GC implementations (such as the current conservative one) don't
905 * support GC memory allocation during object finalization, this function
910 * the GC.
918 assert(!GC.inFinalizer);
942 if (GC.inFinalizer)
950 * Presently, allocating GC memory during finalization
954 * `GC.inFinalizer` can be used to guard against
957 * invoked by the GC.
959 cast(void) GC.malloc(1);
981 GC.collect;
987 GC.runFinalizers((cast(const void*)typeid(Resource).destructor)[0..1]);
1007 * GC.stats().allocatedInCurrentThread, but faster.
1014 ulong currentlyAllocated = GC.allocatedInCurrentThread();
1023 assert(GC.allocatedInCurrentThread() == currentlyAllocated + 32);
1024 assert(GC.stats().allocatedInCurrentThread == currentlyAllocated + 32);
1185 equivalents in the GC API), the behavior is undefined.
1200 See_Also: $(REF1 destroy, object), $(REF free, core,GC)
1204 The `delete` keyword allowed to free GC-allocated memory.
1254 GC.free(GC.addrOf(cast(void*) x));
1259 GC.free(GC.addrOf(cast(void*) x.ptr));
1280 assert(GC.addrOf(cast(void*) b) != null);
1284 assert(GC.addrOf(cast(void*) b) == null);
1287 assert(GC.addrOf(cast(void*) a) == null); // but not a valid GC pointer
1314 assert(GC.addrOf(cast(void*) a) != null);
1318 assert(GC.addrOf(cast(void*) a) == null);
1335 assert(GC.addrOf(cast(void*) a) != null);
1339 assert(GC.addrOf(cast(void*) a) == null);
1352 assert(GC.addrOf(b.ptr) != null);
1355 assert(GC.addrOf(b.ptr) == null);
1358 assert(GC.addrOf(a.ptr) == null); // but not a valid GC pointer
1379 assert(GC.addrOf(arr.ptr) != null);
1382 assert(GC.addrOf(arr.ptr) == null);
1388 import core.memory : GC;
1389 auto a = GC.malloc(5);
1390 assert(GC.addrOf(cast(void*) a) != null);
1393 assert(GC.addrOf(cast(void*) a) == null);
1420 assert(GC.addrOf(x.ptr) != null);
1423 assert(GC.addrOf(x.ptr) == null);
1426 assert(GC.addrOf(y.ptr) != null);
1429 assert(GC.addrOf(y.ptr) == null);
1447 int* p = cast(int*) GC.malloc(memsize * int.sizeof);
1452 int* q = cast(int*) GC.realloc(p + 4, 2 * memsize * int.sizeof);
1455 q = cast(int*) GC.realloc(p + memsize / 2, 2 * memsize * int.sizeof);
1458 q = cast(int*) GC.realloc(p + memsize - 1, 2 * memsize * int.sizeof);
1461 int* r = cast(int*) GC.realloc(p, 5 * memsize * int.sizeof);
1465 int* s = cast(int*) GC.realloc(r, 2 * memsize * int.sizeof);
1468 assert(GC.realloc(s, 0) == null); // free
1469 assert(GC.addrOf(p) == null);
1478 void* p = GC.malloc(100);
1479 assert(GC.realloc(&p, 50) == null); // non-GC pointer
1482 // test GC.profileStats
1485 auto stats = GC.profileStats();
1486 GC.collect();
1487 auto nstats = GC.profileStats();
1495 Moves a value to a new GC allocation.
1502 A pointer to the new GC-allocated value.