MemoryInfo Class — spring-boot Architecture
Architecture documentation for the MemoryInfo class in ProcessInfo.java from the spring-boot codebase.
Entity Profile
Source Code
core/spring-boot/src/main/java/org/springframework/boot/info/ProcessInfo.java lines 261–354
public static class MemoryInfo {
private static final MemoryMXBean memoryMXBean = ManagementFactory.getMemoryMXBean();
private static final List<GarbageCollectorMXBean> garbageCollectorMXBeans = ManagementFactory
.getGarbageCollectorMXBeans();
private final MemoryUsageInfo heap;
private final MemoryUsageInfo nonHeap;
private final List<GarbageCollectorInfo> garbageCollectors;
MemoryInfo() {
this.heap = new MemoryUsageInfo(memoryMXBean.getHeapMemoryUsage());
this.nonHeap = new MemoryUsageInfo(memoryMXBean.getNonHeapMemoryUsage());
this.garbageCollectors = garbageCollectorMXBeans.stream().map(GarbageCollectorInfo::new).toList();
}
public MemoryUsageInfo getHeap() {
return this.heap;
}
public MemoryUsageInfo getNonHeap() {
return this.nonHeap;
}
/**
* Garbage Collector information for the process. This list provides details about
* the currently used GC algorithms selected by the user or JVM ergonomics. It
* might not be trivial to know the used GC algorithms since that usually depends
* on the {@link Runtime#availableProcessors()} (see:
* {@link ProcessInfo#getCpus()}) and the available memory (see:
* {@link MemoryUsageInfo}).
* @return {@link List} of {@link GarbageCollectorInfo}.
* @since 3.5.0
*/
public List<GarbageCollectorInfo> getGarbageCollectors() {
return this.garbageCollectors;
}
public static class MemoryUsageInfo {
private final MemoryUsage memoryUsage;
MemoryUsageInfo(MemoryUsage memoryUsage) {
this.memoryUsage = memoryUsage;
}
public long getInit() {
return this.memoryUsage.getInit();
}
public long getUsed() {
return this.memoryUsage.getUsed();
}
public long getCommitted() {
return this.memoryUsage.getCommitted();
}
public long getMax() {
return this.memoryUsage.getMax();
}
}
/**
* Garbage collection information.
*
* @since 3.5.0
*/
public static class GarbageCollectorInfo {
private final String name;
private final long collectionCount;
GarbageCollectorInfo(GarbageCollectorMXBean garbageCollectorMXBean) {
this.name = garbageCollectorMXBean.getName();
this.collectionCount = garbageCollectorMXBean.getCollectionCount();
}
public String getName() {
return this.name;
}
public long getCollectionCount() {
return this.collectionCount;
}
}
}
Source
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free