Skip to content

aragozin/heapunit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HeapUnit

Test library to introspecting your Java heap via heap dumps.

HeapUnit can

  • capture heap dump of own JVM
  • scan content of dump
  • reconstruct Java objects from heap dump

Example

Code snippet below dumps TCP Socket instances found in heap

HeapImage hi = HeapUnit.captureHeap();
	
for(HeapInstance i: hi.instances(SocketImpl.class)) {
	// fd field in SocketImpl class is nullified when socket gets closed
	boolean open = i.value("fd") != null;
	System.out.println(i.rehydrate() + (open ? " - open" : " - closed"));
}

Full source is here

Maven artifact

HeapUnit and dependencies is available in Maven Central Repo

<dependency>
    <groupId>org.gridkit.heapunit</groupId>
    <artifactId>heapunit</artifactId>
    <version>0.2</version>
</dependency>

About

Heap introspection for test puposes

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages