Expand description
A library for parsing hprof files.
See parse_hprof to get started, or see the examples in the repo.
§Examples
Iterating across all records to count how many of each record type there are (adapted from
the analyze_hprof
example’s record-counts
subcommand):
use std::{fs, collections};
use jvm_hprof::{Hprof, parse_hprof, RecordTag, EnumIterable};
fn count_records(file: fs::File) {
let memmap = unsafe { memmap::MmapOptions::new().map(&file) }.unwrap();
let hprof: Hprof = parse_hprof(&memmap[..]).unwrap();
// start with zero counts for all types
let mut counts = RecordTag::iter()
.map(|r| (r, 0_u64))
.collect::<collections::HashMap<RecordTag, u64>>();
// overwrite zeros with real counts for each record that exists in the hprof
hprof
.records_iter()
.map(|r| r.unwrap().tag())
.for_each(|tag| {
counts.entry(tag).and_modify(|c| *c += 1).or_insert(1);
});
let mut counts: Vec<(RecordTag, u64)> = counts
.into_iter()
.collect::<Vec<(jvm_hprof::RecordTag, u64)>>();
// highest count on top
counts.sort_unstable_by_key(|&(_, count)| count);
counts.reverse();
for (tag, count) in counts {
println!("{:?}: {}", tag, count);
}
}
Modules§
- heap_
dump - Sub records contained in crate::HeapDumpSegment records.
Structs§
- Header
- Basic metadata about the hprof
- Heap
Dump Segment - Contents of a Record with tag RecordTag::HeapDump or RecordTag::HeapDumpSegment.
- Hprof
- The top level of data loaded from an .hprof file.
- Id
- Ids are used to identify many things in an hprof file: objects, classes, utf8 blobs, etc.
- Ids
- Iterator that parses ids.
- Load
Class - Contents of a Record with tag RecordTag::LoadClass.
- Record
- The next level down from the Hprof in the hierarchy of data.
- Record
TagIter - Records
- Iterator over the Record data in an hprof.
- Serial
- An alternate means of identification used in parallel with Id.
- Stack
Frame - Contents of a Record with tag RecordTag::StackFrame.
- Stack
Trace - Contents of a Record with tag RecordTag::StackTrace.
- SubRecords
- Iterator over heap_dump::SubRecord data.
- Utf8
- Contents of a Record with tag RecordTag::Utf8.
Enums§
- IdSize
- Hprof ids can be 32 or 64 bit, depending on the system and JVM that the hprof was captured on.
- LineNum
- A line referenced from a stack frame.
- Record
Tag - Indicates what type of data is contained in a particular Record.
Traits§
- Enum
Iterable - Allow iterating over enum variants for enums that have
#[derive(EnumIter)]
.
Functions§
- parse_
hprof - Entry point for parsing.