lib/memdump/memory_dump.rb
# Return the graph of object that keeps objects in dump alive
#
# It contains only the shortest paths from the roots to the objects in
# dump
#
# @param [MemoryDump] dump
# @return [MemoryDump]
Return the graph of object that keeps objects in dump alive
It contains only the shortest paths from the roots to the objects in
dump
Return the graph of object that keeps objects in dump alive It contains only the shortest paths from the roots to the objects in dump
def roots_of(dump, root_dump: nil)
            if root_dump && root_dump.empty?
                raise ArgumentError, "no roots provided"
            end
            root_addresses =
                if root_dump then root_dump.addresses
                else
                    ['ALL_ROOTS']
                end
            ensure_graphs_computed
            result_nodes = Set.new
            dump_addresses = dump.addresses
            root_addresses.each do |root_address|
                visitor = RGL::DijkstraVisitor.new(@forward_graph)
                dijkstra = RGL::DijkstraAlgorithm.new(@forward_graph, Hash.new(1), visitor)
                dijkstra.find_shortest_paths(root_address)
                path_builder = RGL::PathBuilder.new(root_address, visitor.parents_map)
                dump_addresses.each_with_index do |record_address, record_i|
                    if path = path_builder.path(record_address)
                        result_nodes.merge(path)
                    end
                end
            end
            find_and_map do |record|
                address = record['address']
                next if !result_nodes.include?(address)
                record = dump.find_by_address(address) || record
                record = record.dup
                record['references'] = result_nodes & record['references']
                record
            end
        end
def roots_of ( dump , root_dump : nil ) if root_dump && root_dump . empty? raise ArgumentError , "no roots provided" end root_addresses = if root_dump then root_dump . addresses else [ 'ALL_ROOTS' ] end ensure_graphs_computed result_nodes = Set . new dump_addresses = dump . addresses root_addresses . each do | root_address | visitor = RGL :: DijkstraVisitor . new ( @forward_graph ) dijkstra = RGL :: DijkstraAlgorithm . new ( @forward_graph , Hash . new ( 1 ) , visitor ) dijkstra . find_shortest_paths ( root_address ) path_builder = RGL :: PathBuilder . new ( root_address , visitor . parents_map ) dump_addresses . each_with_index do | record_address , record_i | if path = path_builder . path ( record_address ) result_nodes . merge ( path ) end end end find_and_map do | record | address = record [ 'address' ] next if ! result_nodes . include? ( address ) record = dump . find_by_address ( address ) || record record = record . dup record [ 'references' ] = result_nodes & record [ 'references' ] record end end
Return the graph of object that keeps objects in dump alive
It contains only the shortest paths from the roots to the objects in
dump
Return the graph of object that keeps objects in dump alive It contains only the shortest paths from the roots to the objects in dump
# Prefer records in 'dump' to allow for annotations in the # source
None
MemoryDump
dump
root_dump
None