# Re: ObjectSpace module

**URL:** <https://www.ruby-forum.com/t/re-objectspace-module/211317>\
**Category:** IronRuby\
**Created:** [September 1, 2011, 9:08am UTC](https://www.ruby-forum.com/t/re-objectspace-module/211317 "2011-09-01T09:08:40Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [September 1, 2011, 9:08am UTC](https://www.ruby-forum.com/t/re-objectspace-module/211317/1 "2011-09-01T09:08:40Z")

</div>

Hello,

Sorry for the late reply.

Implementing directly in the libraries will involve adding some logic  
somewhere in something like RubyInstanceData (where ObjectID is  
implemented, I didn’t investigate in detail yet).

We use this feature: object → object\_id → object.

Thank you!

PS: When a new version of IronRuby will be released?

Regards,

Iulian Fecioru

From: Tomas M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Tuesday, August 16, 2011 9:41 AM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] ObjectSpace module

This is actually pretty good solution - it’s not harming perf of apps  
that don’t need the feature.

Is there any real-world scenario that this doesn’t address?

[Iulian Fecioru] I don’t understand the question

Some app translating random integers to objects?

[Iulian Fecioru] I don’t understand the question

Until there is I’m not sure if it makes sense to go any further. What  
about implementing your approach directly in the libraries?

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Iulian Fecioru  
Sent: Monday, August 15, 2011 10:35 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] ObjectSpace module

Hello,

Thank you for your response.

My implementation was a trick to make something working. I think I can  
do this more correctly and complete in the IronRuby core.

I’ll try to implement this in IronRuby core, if nobody is against this.  
(Something like JRuby has implemented).

Regards,

Iulian Fecioru

From: Tomas M. [[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)]  
Sent: Wednesday, August 10, 2011 7:20 PM  
To: removed\_email\_address@domain.invalid  
Subject: Re: [Ironruby-core] ObjectSpace module

Your implementation of \_id2ref might be a good enough approximation. (It  
isn’t 100% equivalent to MRI though since in MRI I can enumerate  
integers and ask if there is an object with that id. So I can get to  
objects for which object\_id wasn’t called before.)

You “become” a developer by submitting a patch on github. No need to  
talk to anybody J. Of course, it is better to let folks in this list  
know what you’re working on so that we don’t dup efforts.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Iulian Fecioru  
Sent: Tuesday, August 09, 2011 10:51 PM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] ObjectSpace module

Hello,

I’ve wrote on [http://ironruby.codeplex.com/workitem/6028](http://ironruby.codeplex.com/workitem/6028) that the  
ObjectSpace module is not complete

Comments from the issues above: "

wrote Thu at 11:57 PM

File.realpath is a Ruby 1.9 method we haven’t gotten to.

We’re unable to implement those methods of ObjectSpace as we can’t track  
them ourselves as we don’t know when the CLR will garbage collect a  
specific object, and we don’t have access to a list of reachable  
objects.

Renaming this issue to track File.realpath

iulianfecioru wrote Fri at 8:27 AM

> From the previous comment I understand that methods from ObjectSpace  
> (\_id2ref, count\_objects.) will not be supported.

Is this true?!

PS: I’ve added \_id2ref method to the ObjectSpace, so I think it is  
posible but is just my opinion 😉

jimmysch wrote Fri at 4:50 PM

How did you implement \_id2ref in IronRuby? I’m 100% sure we can’t  
implement it without slowing down the entire runtime. ObjectSpace is a  
thin wrapper around MRI’s memory manager, while on the CLR we don’t have  
access to it. Therefore, it’s more MRI’s implementation detail than a  
general Ruby feature. And Ruby library writers already know not to use  
it if they want to run on all Ruby implementations.

That being said, we could implement it poorly and require the user to  
turn it on if they want to use it (like JRuby does:  
[http://kenai.com/projects/jruby/pages/PerformanceTuning#Disabling\_Object](http://kenai.com/projects/jruby/pages/PerformanceTuning#Disabling_Object)  
Space), but I don’t see that as a priority feature. That being said,  
patches are welcome. If you want to discuss this further, let’s move  
this discussion to the mailing list (removed\_email\_address@domain.invalid) or  
open a new feature request  
([http://ironruby.codeplex.com/WorkItem/Create](http://ironruby.codeplex.com/WorkItem/Create)).

"

I think jimmysch is right about the performance issues, but in my case I  
need to have the ObjectSpace.id2ref because we need to send the object  
IDs to native languages and retrieve the objects using this object IDs  
in IronRuby.

I think that the JRuby solution  
([http://kenai.com/projects/jruby/pages/PerformanceTuning#Disabling\_Objec](http://kenai.com/projects/jruby/pages/PerformanceTuning#Disabling_Objec)  
tSpace) should be in IronRuby.

I’ve attached my own trick (I think it is a big performance issue).  
Maybe this could be done in a more better way and directly in IronRuby  
source code.

Thank you!

PS: I would like to become a developer in this project. With who should  
I talk?!

Regards,

* * *

Iulian Fecioru

NAPA Romania SRL

Lead Software Developer

Brailei, 165b, 1

800310, Galati, Romania

Mobile:

+40-722-664027

Phone:

+40-336-802182

Fax:

+40-336-802185
