Sha256: 5b41b4f1198b3ee72f83d461a2c00a63d3ac7eb515b5ac413721eb95181036e5

Contents?: true

Size: 1.12 KB

Versions: 11

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module RubyMemcheck
  class Stack
    attr_reader :configuration, :frames

    def initialize(configuration, stack_xml)
      @configuration = configuration
      @frames = stack_xml.xpath("frame").map { |frame| Frame.new(configuration, frame) }
    end

    def skip?
      in_binary = false

      frames.each do |frame|
        fn = frame.fn

        if frame.in_ruby?
          # If a stack from from the binary was encountered first, then this
          # memory leak did not occur from Ruby
          unless in_binary
            # Skip this stack because it was called from Ruby
            return true if configuration.skipped_ruby_functions.any? { |r| r.match?(fn) }
          end
        elsif frame.in_binary?
          in_binary = true

          # Skip the Init function because it is only ever called once, so
          # leaks in it cannot cause memory bloat
          return true if fn == "Init_#{configuration.binary_name}"
        end
      end

      # Skip if the stack was never in the binary because it is very likely
      # not a leak in the native gem
      !in_binary
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
ruby_memcheck-1.3.2 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.3.1 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.3.0 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.2.0 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.1.2 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.1.1 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.1.0 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.0.3 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.0.2 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.0.1 lib/ruby_memcheck/stack.rb
ruby_memcheck-1.0.0 lib/ruby_memcheck/stack.rb