Skip to content

Instantly share code, notes, and snippets.

[9 : 0] eric@kiccoro:/Users/eric/src > ruby thread_sender.rb
testing 1: #<Thread:0x101419bf8 run>
testing 2: #<Thread:0x101419bf8 run>
#<Thread:0x100170358 run>
diff --git a/lib/god/logger.rb b/lib/god/logger.rb
index 7c45679..b08d0f8 100644
--- a/lib/god/logger.rb
+++ b/lib/god/logger.rb
@@ -58,21 +58,27 @@ module God
def log(watch, level, text)
# initialize watch log if necessary
self.logs[watch.name] ||= Timeline.new(God::LOG_BUFFER_SIZE_DEFAULT) if watch
-
+
(gdb) ruby objects classes
1 YAML::Syck::Resolver
1 YAML::Syck::Resolver
1 SystemStackError
1 Object
1 Object
1 NoMemoryError
1 fatal
1 Object
1 Gem::ConfigFile
@eric
eric / gist:242966
Created November 25, 2009 19:41
Based on a great idea from @jnewland
diff --git a/lib/god/process.rb b/lib/god/process.rb
index 338da5e..6cbc867 100644
--- a/lib/god/process.rb
+++ b/lib/god/process.rb
@@ -6,7 +6,7 @@ module God
:unix_socket, :chroot, :env, :dir
def initialize
- self.log = '/dev/null'
+ self.log = nil
#!/usr/bin/env ruby
def fork_test(command)
pid = Kernel.fork do
exec command
end
puts "parent sees pid: #{pid}"
Process.waitpid(pid)
end
(gdb) ruby objects classes
1 God::Registry
1 God::Socket
1 ActiveSupport::Inflector::Inflections
1 REXML::XMLDecl
1 Resolv::DNS::Config
1 Resolv::DNS
1 Resolv::Hosts
1 Resolv
1 Gem::CommandManager
# Would be nice to be part of scout internals
def counter(name, value, options = {})
current_time = Time.now
if data = memory(name)
last_time, last_value = data[:time], data[:value]
elapsed_seconds = current_time - last_time
# We won't log it if the value has wrapped or enough time hasn't
# elapsed
> ruby spec/memprof_spec.rb
Memprof
- should print stats to a file [FAILED]
- should allow calling ::stats multiple times [FAILED]
- should clear stats after ::stats! [FAILED]
- should collect stats via ::track
- should dump objects as json
- should raise error when calling ::stats or ::dump without ::start
spec/memprof_spec.rb:76: [BUG] Segmentation fault
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2009.10
> gdb --batch -ex 'disasrb_gc_force_recycle' ruby
Using host libthread_db library "/lib/libthread_db.so.1".
Undefined command: "disasrb_gc_force_recycle". Try "help".
CRYPT [22 : 0] eric@vox4:/home/eric > gdb --batch -ex 'disas rb_gc_force_recycle' ruby
Using host libthread_db library "/lib/libthread_db.so.1".
Dump of assembler code for function rb_gc_force_recycle:
0x08069ed2 <rb_gc_force_recycle+0>: push %ebp
0x08069ed3 <rb_gc_force_recycle+1>: mov %esp,%ebp
0x08069ed5 <rb_gc_force_recycle+3>: push %ebx
0x08069ed6 <rb_gc_force_recycle+4>: sub $0x10,%esp
@eric
eric / require_tracking.rb
Created December 28, 2009 02:18
A simple tool to gather memory usage when files are required. More info at: http://bitmonkey.net/post/308322913
#
# Created by Eric Lindvall <[email protected]>
#
# WHAT: Provides a simple overview of memory allocation occuring during a
# require.
#
# For a longer explanation, see my post at:
#
# http://bitmonkey.net/post/308322913/tracking-initial-memory-usage-by-file-in-ruby
#