|
7 | 7 | * Using this module is not necessary in typical D code. It is mostly
|
8 | 8 | * useful when doing low-level _memory management.
|
9 | 9 | *
|
| 10 | + * Notes_to_users: |
| 11 | + * |
| 12 | + $(OL |
| 13 | + $(LI The GC is a conservative mark-and-sweep collector. It only runs a |
| 14 | + collection cycle when an allocation is requested of it, never |
| 15 | + otherwise. Hence, if the program is not doing allocations, |
| 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. |
| 19 | + ) |
| 20 | + $(LI If there are threads that the GC does not know about, i.e. the threads |
| 21 | + were created by calling the operating system thread creation APIs |
| 22 | + directly, or the C runtime thread creation APIs directly, and those |
| 23 | + threads hold references to GC allocated data, then the GC will not detect |
| 24 | + those references and may free the data. This will cause memory corruption. |
| 25 | + There are several ways to resolve this issue: |
| 26 | + $(OL |
| 27 | + $(LI Do not hold references to GC allocated data in such threads.) |
| 28 | + $(LI Register/unregister such data with calls to $(LREF addRoot)/$(LREF removeRoot) and |
| 29 | + $(LREF addRange)/$(LREF removeRange).) |
| 30 | + $(LI Maintain another reference to that same data in another thread that the |
| 31 | + GC does know about.) |
| 32 | + $(LI Disable GC collection cycles while that thread is active with $(LREF disable)/$(LREF enable).) |
| 33 | + $(LI Register the thread with the GC using $(CXREF thread, thread_attachThis)/$(CXREF thread, thread_detachThis).) |
| 34 | + ) |
| 35 | + ) |
| 36 | + ) |
| 37 | + * |
10 | 38 | * Notes_to_implementors:
|
11 | 39 | * $(UL
|
12 | 40 | * $(LI On POSIX systems, the signals SIGUSR1 and SIGUSR2 are reserved
|
|
67 | 95 | * happens and there is insufficient _memory available.)
|
68 | 96 | * )
|
69 | 97 | *
|
70 |
| - * Copyright: Copyright Sean Kelly 2005 - 2009. |
| 98 | + * Copyright: Copyright Sean Kelly 2005 - 2015. |
71 | 99 | * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
|
72 | 100 | * Authors: Sean Kelly, Alex Rønne Petersen
|
73 | 101 | * Source: $(DRUNTIMESRC core/_memory.d)
|
74 | 102 | */
|
75 | 103 |
|
76 |
| -/* Copyright Sean Kelly 2005 - 2009. |
77 |
| - * Distributed under the Boost Software License, Version 1.0. |
78 |
| - * (See accompanying file LICENSE or copy at |
79 |
| - * http://www.boost.org/LICENSE_1_0.txt) |
80 |
| - */ |
81 | 104 | module core.memory;
|
82 | 105 |
|
83 | 106 |
|
|
0 commit comments