Re: [Gc] Iterating over allocated objects?

Bruce Hoult <[email protected]> Sun, 28 Aug 2016 07:58:05 +1200
Newsgroups gmane.comp.programming.garbage-collection.boehmgc
Message-ID <CAMU+Ekz4TiccyM0ou+TdywMEVsKqG7BEnxNV8_WeHnD=b7LXeg@mail.gmail.com>
--===============0598943552==
Content-Type: multipart/alternative; boundary=047d7b4512a2abb07d053b130c5a

--047d7b4512a2abb07d053b130c5a
Content-Type: text/plain; charset=UTF-8

There's no exposed API for this, no. There are of course internal ways for
the GC to do this, which may change from release to release of the GC --
although they're pretty stable at this point.

The GC allocates memory in blocks of generally 4 kB. Each block is divided
into objects of the same size (allocated size .. may be a little more than
was asked for in GC_malloc, generally the next multiple of 16 bytes or so).
Each block keeps a list of free objects in the block, and mark bits for the
block.

You can iterate through all blocks using the
internal GC_apply_to_all_blocks() function, or through all objects with
the GC_apply_to_each_object() function. It would be your job to make sure
the object is not on the free list, and/or is reachable if that is
important to you. The object was reachable AT THE LAST GC (or at least mark
phase) if the mark bit is set, and it's not on the free list. Objects may
have become unreachable since the last GC.

What are you really trying to do?

On Sun, Aug 28, 2016 at 5:04 AM, Bruno Loff <[email protected]> wrote:

> Dear all,
>
> I am using the bdwgc library for maintaining various allocated objects
> in memory.
>
> I would like to know: is there a mechanism for iterating over every
> chunk that was allocated via gc_malloc?
>
> Thank you for your time,
> Bruno Loff
> _______________________________________________
> bdwgc mailing list
> [email protected]
> https://lists.opendylan.org/mailman/listinfo/bdwgc
>
> --
> This message has been scanned for viruses and
> dangerous content by MailScanner, and is
> believed to be clean.
>
>

--047d7b4512a2abb07d053b130c5a
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">There&#39;s no exposed API for this, no. There are of cour=
se internal ways for the GC to do this, which may change from release to re=
lease of the GC -- although they&#39;re pretty stable at this point.<div><b=
r></div><div>The GC allocates memory in blocks of generally 4 kB. Each bloc=
k is divided into objects of the same size (allocated size .. may be a litt=
le more than was asked for in GC_malloc, generally the next multiple of 16 =
bytes or so). Each block keeps a list of free objects in the block, and mar=
k bits for the block.</div><div><br></div><div>You can iterate through all =
blocks using the internal=C2=A0GC_apply_to_all_blocks() function, or=C2=A0t=
hrough=C2=A0all=C2=A0objects with the=C2=A0GC_apply_to_each_object() functi=
on. It would be your job to make sure the object is not on the free list, a=
nd/or is reachable if that is important to you. The object was reachable AT=
 THE LAST GC (or at least mark phase) if the mark bit is set, and it&#39;s =
not on the free list. Objects may have become unreachable since the last GC=
.</div><div><br></div><div>What are you really trying to do?</div></div><di=
v class=3D"gmail_extra"><br><div class=3D"gmail_quote">On Sun, Aug 28, 2016=
 at 5:04 AM, Bruno Loff <span dir=3D"ltr">&lt;<a href=3D"mailto:bruno.loff@=
gmail.com" target=3D"_blank">[email protected]</a>&gt;</span> wrote:<br>=
<blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;border-left:1p=
x #ccc solid;padding-left:1ex">Dear all,<br>
<br>
I am using the bdwgc library for maintaining various allocated objects<br>
in memory.<br>
<br>
I would like to know: is there a mechanism for iterating over every<br>
chunk that was allocated via gc_malloc?<br>
<br>
Thank you for your time,<br>
Bruno Loff<br>
______________________________<wbr>_________________<br>
bdwgc mailing list<br>
<a href=3D"mailto:[email protected]">[email protected]</a><=
br>
<a href=3D"https://lists.opendylan.org/mailman/listinfo/bdwgc" rel=3D"noref=
errer" target=3D"_blank">https://lists.opendylan.org/<wbr>mailman/listinfo/=
bdwgc</a><br>
<span class=3D"HOEnZb"><font color=3D"#888888"><br>
--<br>
This message has been scanned for viruses and<br>
dangerous content by MailScanner, and is<br>
believed to be clean.<br>
<br>
</font></span></blockquote></div><br></div>

--047d7b4512a2abb07d053b130c5a--

--===============0598943552==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
bdwgc mailing list
[email protected]
https://lists.opendylan.org/mailman/listinfo/bdwgc
--===============0598943552==--