From c6425e569916dd5dc941909097af42d0c7a7ac3a Mon Sep 17 00:00:00 2001 From: Jim Myhrberg Date: Sat, 7 Jul 2018 22:25:24 +0100 Subject: [PATCH] Rename HeapDump to ObjectDump --- main.go | 6 +++--- heap_dump.go => object_dump.go | 14 +++++++------- 2 files changed, 10 insertions(+), 10 deletions(-) rename heap_dump.go => object_dump.go (79%) diff --git a/main.go b/main.go index 6bb5a5a..f52cf75 100644 --- a/main.go +++ b/main.go @@ -55,14 +55,14 @@ func logMsg(msg string) { } } -func loadDump(filePath string) (*HeapDump, error) { +func loadDump(filePath string) (*ObjectDump, error) { logMsg(fmt.Sprintf("--> Loading %s...", filePath)) - dump, err := NewHeapDump(filePath) + dump, err := NewObjectDump(filePath) logMsg(fmt.Sprintf(" Loaded %d addresses", len(dump.Index))) return dump, err } -func printHexDiff(leaked *[]string, dump *HeapDump) { +func printHexDiff(leaked *[]string, dump *ObjectDump) { for _, index := range *leaked { if entry, ok := dump.Entries[index]; ok { fmt.Println(entry.Object.Address) diff --git a/heap_dump.go b/object_dump.go similarity index 79% rename from heap_dump.go rename to object_dump.go index 636a74a..24707ed 100644 --- a/heap_dump.go +++ b/object_dump.go @@ -8,21 +8,21 @@ import ( "sort" ) -func NewHeapDump(file string) (*HeapDump, error) { - heapDump := HeapDump{File: file} +func NewObjectDump(file string) (*ObjectDump, error) { + heapDump := ObjectDump{File: file} err := heapDump.Process() return &heapDump, err } -// HeapDump contains all relevant data for a single heap dump. -type HeapDump struct { +// ObjectDump contains all relevant data for a single heap dump. +type ObjectDump struct { File string Index []string Entries map[string]*Entry } // Process processes the heap dump -func (s *HeapDump) Process() error { +func (s *ObjectDump) Process() error { file, err := os.Open(s.File) defer file.Close() @@ -56,7 +56,7 @@ func (s *HeapDump) Process() error { return nil } -func (s *HeapDump) PrintMatchingJSON(indexes *[]string) error { +func (s *ObjectDump) PrintMatchingJSON(indexes *[]string) error { file, err := os.Open(s.File) defer file.Close() @@ -88,7 +88,7 @@ func (s *HeapDump) PrintMatchingJSON(indexes *[]string) error { return nil } -func (s *HeapDump) matchingOffsets(indexes *[]string) []int64 { +func (s *ObjectDump) matchingOffsets(indexes *[]string) []int64 { var offsets []int64 for _, index := range *indexes {