Rename HeapDump to ObjectDump

This commit is contained in:
2018-07-07 22:25:24 +01:00
parent d3e8f08f54
commit c6425e5699
2 changed files with 10 additions and 10 deletions

View File

@@ -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)

View File

@@ -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 {