Class: Oink::Instrumentation::WindowsMemorySnapshot

Inherits:
Object
  • Object
show all
Defined in:
lib/oink/instrumentation/memory_snapshot.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.available?Boolean

Returns:

  • (Boolean)


40
41
42
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 40

def self.available?
  defined? WIN32OLE
end

Instance Method Details

#memoryObject



30
31
32
33
34
35
36
37
38
# File 'lib/oink/instrumentation/memory_snapshot.rb', line 30

def memory
  wmi = WIN32OLE.connect("winmgmts:root/cimv2")
  mem = 0
  query = "select * from Win32_Process where ProcessID = #{$$}"
  wmi.ExecQuery(query).each do |wproc|
    mem = wproc.WorkingSetSize
  end
  mem.to_i / 1000
end