digitalmars.D.learn - How does GC.addRange work?
- Gary Willoughby (7/7) Sep 20 2014 How does GC.addRange work? i.e. what is it doing? I'm assuming
- ketmar via Digitalmars-d-learn (9/13) Sep 20 2014 On Sat, 20 Sep 2014 20:14:35 +0000
- Gary Willoughby (3/8) Sep 20 2014 So zeroing values will inform the GC the reference has gone?
- ketmar via Digitalmars-d-learn (4/5) Sep 20 2014 On Sat, 20 Sep 2014 22:21:13 +0000
- Gary Willoughby (3/8) Sep 21 2014 Thanks, i just wanted to make it clear in my mind.
- Steven Schveighoffer (7/16) Sep 22 2014 Just to be crystal clear, zeroing values in that range will make the GC
- kiran kumari (4/11) Sep 24 2014 see more example
How does GC.addRange work? i.e. what is it doing? I'm assuming reading the docs that it adds a range for the GC to scan but what actually happens? Does the GC look into this range and check for the existence of pointers it's currently managing? For example, if i nulled a pointer in the range i added would that trigger the GC to collect that resource on the next sweep? (assuming it was the last reference.)
Sep 20 2014
On Sat, 20 Sep 2014 20:14:35 +0000 Gary Willoughby via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:How does GC.addRange work? i.e. what is it doing? I'm assuming=20 reading the docs that it adds a range for the GC to scan but what=20 actually happens? Does the GC look into this range and check for=20 the existence of pointers it's currently managing?yes. this adds GC "root". but normal GC root is just a single pointer, and "range root" as a memory region that will be scanned for pointers (i.e. something like "array of pointers"). note that scan is conservative, so if you happen to have some integer value that can be interpreted as pointer to GC-managed memory, it will be considered as pointer.
Sep 20 2014
On Saturday, 20 September 2014 at 20:44:18 UTC, ketmar via Digitalmars-d-learn wrote:note that scan is conservative, so if you happen to have some integer value that can be interpreted as pointer to GC-managed memory, it will be considered as pointer.So zeroing values will inform the GC the reference has gone?
Sep 20 2014
On Sat, 20 Sep 2014 22:21:13 +0000 Gary Willoughby via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:So zeroing values will inform the GC the reference has gone?yes.
Sep 20 2014
On Saturday, 20 September 2014 at 23:08:08 UTC, ketmar via Digitalmars-d-learn wrote:On Sat, 20 Sep 2014 22:21:13 +0000 Gary Willoughby via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks, i just wanted to make it clear in my mind.So zeroing values will inform the GC the reference has gone?yes.
Sep 21 2014
On 9/21/14 3:00 PM, Gary Willoughby wrote:On Saturday, 20 September 2014 at 23:08:08 UTC, ketmar via Digitalmars-d-learn wrote:Just to be crystal clear, zeroing values in that range will make the GC able to collect the memory that those values previously pointed at. However, you have to remove the range in order for the GC to ignore that data. In other words, if you zero that memory, the GC will continue to scan those zeros until you GC.removeRange it. -SteveOn Sat, 20 Sep 2014 22:21:13 +0000 Gary Willoughby via Digitalmars-d-learn <digitalmars-d-learn puremagic.com> wrote:Thanks, i just wanted to make it clear in my mind.So zeroing values will inform the GC the reference has gone?yes.
Sep 22 2014
On Saturday, 20 September 2014 at 20:14:36 UTC, Gary Willoughby wrote:How does GC.addRange work? i.e. what is it doing? I'm assuming reading the docs that it adds a range for the GC to scan but what actually happens? Does the GC look into this range and check for the existence of pointers it's currently managing? For example, if i nulled a pointer in the range i added would that trigger the GC to collect that resource on the next sweep? (assuming it was the last reference.)see more example http://techgurulab.com/course/java-quiz-online/
Sep 24 2014