so…you use forkoff and it seems to “jump” the block and not execute it?
In my case I was doing something like
[1].forkoff {
0/0 # this raises, kills the child thread, and the parent continues
}
Monthly Archives: September 2008
kicking the ruby garbage collector’s trash [how to improve memory usage for MRI]
Here’s some pointers I’ve found helpful:
fork off child processes to do a lot of memory usage then die–that way you for sure reclaim that memory
use GC in another child process [email me for details]
Use temp files — Marshal.dump large quantities of data to them while you’re not using it, then Marshal.load it when it is desired.
slim_attributes helps with mysql related usage.
Here’s some more intense options:
rewrite erb to re-use strings
write a “slim array” that encompasses simple ints and strings and floats more memory efficiently than Ruby’s currently does.
ruby fork off forkoff
so…looking for an easy way to fork a child process and have it return information to the parent?
look no further than forkoff
http://codeforpeople.com/lib/ruby/forkoff/forkoff-0.0.4/README
ruby woe — eval is its own scope
ever get
eval(“yoyo = 3″)
raise unless yoyo
yielding ”
./syncer.rb:105: undefined local variable or method `yoyo’ for main:Object (NameError)
turns out that eval is actually its own scope
fix:
yoyo=nil
eval(“yoyo = 3″)
raise unless yoyo
how to run a single spec file in rails
so…you’ve got a lot of specs in RAILS_ROOT/spec/XXX/YYY
to run just one
[well, besides running auto spec or what not--more intense]
just run
ruby spec/XXX/YYY.rb
mod_rails woe
I start one up and get “403 forbidden” errors:
answer:
http://www.modrails.com/documentation/Users%20guide.html#_resource_control_and_optimization_options
6.3.4
drivers for qwest 2wire gray 802.11g grey
So…you found an old gray qwest usb and want to install drivers for windows on it [when you plug it in it says “cannot install this hardware”
Turns out you can get drivers for this “legacy” hardware go to http://support.2wire.com/index.php?page=download then choose adapters -> legacy hardware -> 802.11g gray
If you’ve already told windows to “never try to install drivers again” then you may want to go to the device manager and delete the device, unplug it, reboot, and then plug it in again.
Questions leave a comment.
-=R
planetlab 5 second pauses
if you get 5 second pauses on planetlab–it’s DNS. Accomodate accordingly
ruby tempfile is slow
so…you make some tempfiles and it starts taking like 10s to create after you make lots of them?
Turns out that if you use the same name, on creation, if you reuse the same name, it always starts at 0 and searches for the first non-used number starting with that name. So…O(N^2). How to fix: use different names each time.
Cheers.
-=R
rubydoctest woe
/home/rdp/i386/gemrepository/gems/rubydoctest-1.0.0/bin/../lib/code_block.rb:55:in `actual_result’: undefined method `actual_result’ for nil:NilClass (NoMethodError)
for me meant “you named a test rubydoctest instead of doctest!” and also meant “you have some weird comment syntaxes that look ALMOST like a doctest.
To fix: at code_block.rb:55 put in an ‘return ‘unknown’ unless @statements.last_whatever it is