Forum: Ruby ObjectSpace#allocation_class_path does not work as expected.

15a0a233d3bf86fea7bbaa525f33897d?d=identicon&s=25 Rajeev N B (Guest)
on 2014-06-12 14:58
(Received via mailing list)
Using Ruby Version 2.1.2

class A def foo ObjectSpace::trace_object_allocations do obj =
Object.new p "#{ObjectSpace::allocation_class_path(obj)}" end end end
A.new.foo #=> "Class"

The above method is expected to return back the allocation class path of
the object. But I am getting an empty string back instead of "Class". Is
it an implementation bug in the method or the documentation is not
updated.


Here is link
(http://www.ruby-doc.org/stdlib-2.1.1/libdoc/objspa...)
for the standard library.
15a0a233d3bf86fea7bbaa525f33897d?d=identicon&s=25 Rajeev Bharshetty (rshetty)
on 2014-06-12 15:14
class A
  def foo
    ObjectSpace::trace_object_allocations do
      obj = Object.new
      p "#{ObjectSpace::allocation_class_path(obj)}"
    end
  end
 end

Expected: A.new.foo #=> "Class"
Actual: A.new.foo #=> ""
4be91d1e04fd298e6122f99d6abcb88b?d=identicon&s=25 Jeremy Axelrod (Guest)
on 2014-06-12 18:45
(Received via mailing list)
Did you add require 'objspace'

Sent from my phone
15a0a233d3bf86fea7bbaa525f33897d?d=identicon&s=25 Rajeev Bharshetty (rshetty)
on 2014-06-12 18:48
Jeremy: Yes I did. The same seems to work in a rails console.
But not in ruby IRB.
620676bac4e81aae46ba1f252dbc76ce?d=identicon&s=25 Rylee Fowler (rylee)
on 2014-06-12 18:51
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Even when requiring 'objspace', I get an empty return statement.

> [1] pry(main)> require 'objspace' => true [2] pry(main)> class A
> [2] pry(main)*   def foo [2] pry(main)*
> ObjectSpace::trace_object_allocations do [2] pry(main)*       obj =
> Object.new [2] pry(main)*       p
> "#{ObjectSpace::allocation_class_path(obj)}" [2] pry(main)*
> end [2] pry(main)*   end [2] pry(main)* end => :foo [3] pry(main)>
> [4] pry(main)> A.new.foo "" => ""



On 6/12/2014 12:44, Jeremy Axelrod wrote:
>> |class A def foo ObjectSpace::trace_object_allocations do obj =
>> Here is link
>> <http://www.ruby-doc.org/stdlib-2.1.1/libdoc/objspa...
>> for the standard library.
>>
>>
>> -- Rajeev N Bharshetty Sent with Sparrow
>> <http://www.sparrowmailapp.com/?sig>
>>

- --
Rylee Fowler
rylee@rylee.me
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCgAGBQJTmdp2AAoJEAWmNCH2N+MzxngIAIjIj0+qk2iVUNJa/vLycSyc
LjKrWYh1W5lpl8HFQV0pIj3YUx+f+ZpractGGBX6XWua9xl5sJE4xecaLs+R3yVw
N9ljnAKXzu1WbsRyZPeJ76pTF23i0jGK+uhCx0nVcq0VxULFEGCS74/nhcSgiP74
JTKCFFS7kMW/W29JiCm9CeMjqy+PFfBioZ8D3RzhRt7RJbilCXW2fIjQW51PmHQ3
hMYvgwXRdkN8O0g2x6i/pugb+epRpUu0VZAIUcpIqMqHOBIKReDFDZ9dBcCav22+
UzJS+X2PTh7obSfBB9vI3yaIaydctJQqUBD7bNpqwkBdsj4o76ZNC1frCja5f1k=
=YWCR
-----END PGP SIGNATURE-----
620676bac4e81aae46ba1f252dbc76ce?d=identicon&s=25 Rylee Fowler (rylee)
on 2014-06-12 18:53
(Received via mailing list)
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Oh dear, Thunderbird butchered that.

[1] pry(main)> require 'objspace'
=> true
[2] pry(main)> class A
[2] pry(main)*   def foo
[2] pry(main)*     ObjectSpace::trace_object_allocations do
[2] pry(main)*       obj = Object.new
[2] pry(main)*       p "#{ObjectSpace::allocation_class_path(obj)}"
[2] pry(main)*     end
[2] pry(main)*   end
[2] pry(main)* end
=> :foo
[3] pry(main)>
[4] pry(main)> A.new.foo
""
=> ""



On 6/12/2014 12:51, Rylee Fowler wrote:
>
>>> Using Ruby Version 2.1.2
>>> or the documentation is not updated.
>>>
>>> Here is link
>>> <http://www.ruby-doc.org/stdlib-2.1.1/libdoc/objspa...
>>>
>>>
for the standard library.
>>>
>>>
>>> -- Rajeev N Bharshetty Sent with Sparrow
>>> <http://www.sparrowmailapp.com/?sig>
>>>
>
>

- --
Rylee Fowler
rylee@rylee.me
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.22 (MingW32)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCgAGBQJTmdq/AAoJEAWmNCH2N+MzSfEH/1dJb0A1mc5Kh9jWPvijoQbe
anaa9HYrP/JupFoYO+fZAm/A6/FkEgkyBNWonwi1SLv8e9XCbhok0jm+FHDRFKkM
vwsiCBvmh/vASG9mGiOdN1pcUVkzb/etKKQG73xbYpjQH4tG9vS0THUJeJ3pXzq5
YE9pA2FKQcnLaIp/apXYG+Np3Jhod04W9A+j2VDwm08DKyo3I19UkkjFr17XA8H5
MJ4gIkagRIAR6PAV109xjyyVX6kf2zmzOK6tT5Ap18qVpSzQJ3fndpX9Pe6mJjJK
J8+plJpEOSGBHSXmlnEBu4zEbTUzspo5Vel6wemlR7UNzm/pWrpGP8vLHZdSoEI=
=+MO3
-----END PGP SIGNATURE-----
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.