free 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +24 -2
- data/Rakefile +1 -0
- data/lib/free/version.rb +1 -1
- data/test/bench_base.rb +7 -0
- data/test/bench_free.rb +4 -0
- data/test/bench_non_free.rb +4 -0
- data/test/test.rb +2 -2
- metadata +22 -8
data/README.md
CHANGED
@@ -8,10 +8,17 @@ _force immediate garbage collection of Ruby objects_
|
|
8
8
|
free provides the `Object#free` method enabling a user to garbage
|
9
9
|
collect an object on demand and free all its internal structures.
|
10
10
|
|
11
|
-
* Install the [gem](https://rubygems.org/gems/free)
|
11
|
+
* Install the [gem](https://rubygems.org/gems/free): `gem install free`
|
12
12
|
* Read the [documentation](http://rdoc.info/github/banister/free/master/file/README.md)
|
13
13
|
* See the [source code](http://github.com/banister/free)
|
14
14
|
|
15
|
+
`free` also has `rubygems-test` support; to participate, first install
|
16
|
+
free, then:
|
17
|
+
|
18
|
+
1. Install rubygems-test: `gem install rubygems-test`
|
19
|
+
2. Run the test: `gem test free`
|
20
|
+
3. Finally choose 'Yes' to upload the results.
|
21
|
+
|
15
22
|
Example: Freeing a String
|
16
23
|
-------------------------
|
17
24
|
|
@@ -57,7 +64,22 @@ Features and limitations
|
|
57
64
|
* Beta software, beware.
|
58
65
|
* Supports MRI and YARV only.
|
59
66
|
* Not complete protection from freeing silly things, e.g core classes. Be sensible :)
|
60
|
-
* Can be dangerous - `free` will force garbage collection on an object
|
67
|
+
* Can be dangerous - `free` will force garbage collection on an object
|
68
|
+
* even if references to it still exist. Trying to access an already
|
69
|
+
* freed object may result in unexpected behaviour or segfaults.
|
70
|
+
|
71
|
+
### Caveats
|
72
|
+
|
73
|
+
Benchmarks have shown that `free` can significantly improve performance, but only
|
74
|
+
when the objects you free are very large (approximately > 50K
|
75
|
+
in size).
|
76
|
+
|
77
|
+
It is not recommended you free small or medium-sized objects as you will
|
78
|
+
actually negatively impact performance - as the `free` process itself
|
79
|
+
incurs some overhead.
|
80
|
+
|
81
|
+
In general you should benchmark your application with and without
|
82
|
+
`free` before you decide to use it.
|
61
83
|
|
62
84
|
Contact
|
63
85
|
-------
|
data/Rakefile
CHANGED
@@ -21,6 +21,7 @@ def apply_spec_defaults(s)
|
|
21
21
|
s.email = 'jrmair@gmail.com'
|
22
22
|
s.description = s.summary
|
23
23
|
s.require_path = 'lib'
|
24
|
+
s.add_development_dependency("bacon",">=1.1.0")
|
24
25
|
s.homepage = "http://banisterfiend.wordpress.com"
|
25
26
|
s.has_rdoc = 'yard'
|
26
27
|
s.files = Dir["ext/**/extconf.rb", "ext/**/*.h", "ext/**/*.c", "lib/**/*.rb",
|
data/lib/free/version.rb
CHANGED
data/test/bench_base.rb
ADDED
data/test/bench_free.rb
ADDED
data/test/test.rb
CHANGED
@@ -17,7 +17,7 @@ describe Free do
|
|
17
17
|
c = v
|
18
18
|
|
19
19
|
# grab the object id since referring to object directly (through
|
20
|
-
#
|
20
|
+
# v) will likely result in segfault, which can't be rescued.
|
21
21
|
id = v.object_id
|
22
22
|
|
23
23
|
ObjectSpace._id2ref(id).should == v
|
@@ -27,7 +27,7 @@ describe Free do
|
|
27
27
|
|
28
28
|
# Two things may happen if it is properly freed:
|
29
29
|
# 1. The _id2ref resolves to another object (the free slot is
|
30
|
-
#
|
30
|
+
# replaced by a new object)
|
31
31
|
# 2. Calling _id2ref raises an exception, typically a RangeError
|
32
32
|
(ObjectSpace._id2ref(id) != v || lambda { ObjectSpace._id2ref(id) } rescue true).should == true
|
33
33
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: free
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 29
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 0
|
8
7
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
8
|
+
- 6
|
9
|
+
version: 0.2.6
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- John Mair (banisterfiend)
|
@@ -15,10 +14,24 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-27 00:00:00 +13:00
|
19
18
|
default_executable:
|
20
|
-
dependencies:
|
21
|
-
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: bacon
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 1
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
version: 1.1.0
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
22
35
|
description: Force immediate garbage collection of an object.
|
23
36
|
email: jrmair@gmail.com
|
24
37
|
executables: []
|
@@ -54,6 +67,9 @@ files:
|
|
54
67
|
- ext/free/free.c
|
55
68
|
- lib/free/version.rb
|
56
69
|
- lib/free.rb
|
70
|
+
- test/bench_base.rb
|
71
|
+
- test/bench_free.rb
|
72
|
+
- test/bench_non_free.rb
|
57
73
|
- test/test.rb
|
58
74
|
- HISTORY
|
59
75
|
- README.md
|
@@ -72,7 +88,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
72
88
|
requirements:
|
73
89
|
- - ">="
|
74
90
|
- !ruby/object:Gem::Version
|
75
|
-
hash: 3
|
76
91
|
segments:
|
77
92
|
- 0
|
78
93
|
version: "0"
|
@@ -81,7 +96,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
96
|
requirements:
|
82
97
|
- - ">="
|
83
98
|
- !ruby/object:Gem::Version
|
84
|
-
hash: 3
|
85
99
|
segments:
|
86
100
|
- 0
|
87
101
|
version: "0"
|