A module to help debug memory leaks in the watcher.
This commit is contained in:
parent
78dc4a5bfb
commit
a8a74995bf
@ -24,12 +24,37 @@ module Compass
|
|||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
module MemoryDebugger
|
||||||
|
def report_on_instances(type, options = {})
|
||||||
|
@@runs ||= 0
|
||||||
|
@@runs += 1
|
||||||
|
@@object_id_tracker ||= {}
|
||||||
|
@@object_id_tracker[type] ||= []
|
||||||
|
GC.start
|
||||||
|
sleep options.fetch(:gc_pause, 1)
|
||||||
|
count = ObjectSpace.each_object(type) do |obj|
|
||||||
|
if @@runs > 2
|
||||||
|
if options.fetch(:verbose, true) && !@@object_id_tracker[type].include?(obj.object_id)
|
||||||
|
begin
|
||||||
|
puts obj.inspect
|
||||||
|
rescue
|
||||||
|
end
|
||||||
|
puts "#{obj.class.name}:#{obj.object_id}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
@@object_id_tracker[type] << obj.object_id
|
||||||
|
end
|
||||||
|
puts "#{type}: #{count} instances."
|
||||||
|
end
|
||||||
|
end
|
||||||
class WatchProject < UpdateProject
|
class WatchProject < UpdateProject
|
||||||
|
|
||||||
register :watch
|
register :watch
|
||||||
|
|
||||||
attr_accessor :last_update_time, :last_sass_files
|
attr_accessor :last_update_time, :last_sass_files
|
||||||
|
|
||||||
|
include MemoryDebugger
|
||||||
|
|
||||||
def perform
|
def perform
|
||||||
Signal.trap("INT") do
|
Signal.trap("INT") do
|
||||||
puts ""
|
puts ""
|
||||||
@ -116,6 +141,7 @@ module Compass
|
|||||||
begin
|
begin
|
||||||
puts ">>> Change detected to: #{file}"
|
puts ">>> Change detected to: #{file}"
|
||||||
compiler.run
|
compiler.run
|
||||||
|
# report_on_instances(Sass::Importers::Base, :verbose => false)
|
||||||
rescue StandardError => e
|
rescue StandardError => e
|
||||||
::Compass::Exec::Helpers.report_error(e, options)
|
::Compass::Exec::Helpers.report_error(e, options)
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user