--zhXaljGHf11kAtnf
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Feb 21, 2008 at 03:34:52AM +0900, Joel VanderWerf wrote:
> Matthew Metnetsky wrote:
>> At this point I would like to force "obj" to be marked, and freed. But I=
=20
>> am
>> not sure what to do as rb_gc() does mark it, but it never gets freed.
>
> It's actually the other way around: marked objects are _not_ freed. They=
=20
> are marked because they are reachable from some other live object.

Understood.

> Question: what kind of variable is your obj:
>
> 	VALUE obj =3D rb_class_new_instance(...)
>
> If it is a stack variable, try setting obj =3D Qnil after unregistering i=
t=20
> (in fact, IIUC register/unregister is not even necessary in this case,=20
> because of the way rb_gc() treats the stack).

obj is a T_OBJECT but it's extending a class who's super() calls Data_Wrap_=
Struct. And to make it worse, the constructor argument is a T_DATA as well.

I reassigned my hold of obj to Qnil like you suggested, but mark is still g=
etting called on both of the previously mentioned objects. Is there somethi=
ng special that I need to do to every VALUE reference I get or create befor=
e letting them go out of scope?

Also, as my mark functions are being called through gc_mark_children, is th=
ere a way to determine their parents?

Thanks a lot!

~ Matthew


--zhXaljGHf11kAtnf
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: Digital signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHvIHMLrcoBjlTBf0RAlH4AJ9UQwcpa/MAkW5yT14bI4YqH0H6mgCdGs4Q
pIfZCW2xHzgEGP0p5XiUsSE=
=RTDK
-----END PGP SIGNATURE-----

--zhXaljGHf11kAtnf--

On Thu, Feb 21, 2008 at 03:34:52AM +0900, Joel VanderWerf wrote:
> Matthew Metnetsky wrote:
>> At this point I would like to force "obj" to be marked, and freed. But I=
=20
>> am
>> not sure what to do as rb_gc() does mark it, but it never gets freed.
>
> It's actually the other way around: marked objects are _not_ freed. They=
=20
> are marked because they are reachable from some other live object.

Understood.

> Question: what kind of variable is your obj:
>
> 	VALUE obj =3D rb_class_new_instance(...)
>
> If it is a stack variable, try setting obj =3D Qnil after unregistering i=
t=20
> (in fact, IIUC register/unregister is not even necessary in this case,=20
> because of the way rb_gc() treats the stack).

obj is a T_OBJECT but it's extending a class who's super() calls Data_Wrap_=
Struct. And to make it worse, the constructor argument is a T_DATA as well.

I reassigned my hold of obj to Qnil like you suggested, but mark is still g=
etting called on both of the previously mentioned objects. Is there somethi=
ng special that I need to do to every VALUE reference I get or create befor=
e letting them go out of scope?

Also, as my mark functions are being called through gc_mark_children, is th=
ere a way to determine their parents?

Thanks a lot!

~ Matthew

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFHvIHMLrcoBjlTBf0RAlH4AJ9UQwcpa/MAkW5yT14bI4YqH0H6mgCdGs4Q
pIfZCW2xHzgEGP0p5XiUsSE=
=RTDK
-----END PGP SIGNATURE-----