⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (786 Bytes)
Bug #11490
ยป allocation_tracker_bug.rb
chancancode (Godfrey Chan)
, 08/27/2015 07:38 AM
require
'objspace'
Kernel
.
module_eval
do
if
defined?
(
gem_original_require
)
alias_method
:original_require
,
:gem_original_require
else
alias_method
:original_require
,
:require
end
def
require
(
path
)
original_require
(
path
)
end
end
nokogiri_gemspec
=
Gem
::
Specification
.
stubs
.
find
{
|
gem
|
gem
.
name
==
'nokogiri'
}
nokogiri_gemspec
.
require_paths
.
each
{
|
path
|
$:
<<
File
.
expand_path
(
path
,
nokogiri_gemspec
.
full_gem_path
)
}
ObjectSpace
.
trace_object_allocations
{
require
'nokogiri'
}
allocations
=
Hash
.
new
(
0
)
ObjectSpace
.
each_object
do
|
obj
|
allocations
[
"
#{
ObjectSpace
.
allocation_sourcefile
(
obj
)
}
:
#{
ObjectSpace
.
allocation_sourceline
(
obj
)
}
"
]
+=
1
end
allocations
.
to_a
.
sort_by
{
|
(
_
,
count
)
|
-
count
}.
each
do
|
(
source
,
count
)
|
puts
"
#{
source
}
=>
#{
count
}
"
end
(1-1/1)
Loading...