Class: NewRelic::Agent::Samplers::MemorySampler::JavaHeapSampler

Inherits:
Base
  • Object
show all
Defined in:
lib/new_relic/agent/samplers/memory_sampler.rb

Instance Method Summary collapse

Methods inherited from Base

#can_run?, #get_sample, #initialize

Constructor Details

This class inherits a constructor from NewRelic::Agent::Samplers::MemorySampler::Base

Instance Method Details

#get_memoryObject



102
103
104
105
106
# File 'lib/new_relic/agent/samplers/memory_sampler.rb', line 102

def get_memory
  raise "Can't sample Java heap unless running in JRuby" unless defined? JRuby

  java.lang.Runtime.getRuntime.totalMemory / (1024 * 1024).to_f rescue nil
end

#to_sObject



108
109
110
# File 'lib/new_relic/agent/samplers/memory_sampler.rb', line 108

def to_s
  'JRuby Java heap sampler'
end