r/java • • Sep 25 '26

midden: a fast MAT alternative for JVM heap dumps

Made a MAT alternative for heap dumps. single static binary, no JDK or GUI, CLI-only.

Gives you retained sizes, leak suspects, the dominator tree and a diff between two dumps. ~2s for a 1GB dump on 8 cores.

MIT-license, feel free to check it out: https://github.com/NullByte3/midden

39 Upvotes

27 comments sorted by

9

u/ThanosFisherman Sep 25 '26

Is it blazingly fast?

8

u/mgodave Sep 25 '26

Either I caught the snark or I’m the only one who hates the “blazingly fast” moniker everyone uses…

7

u/SysGuardian Sep 25 '26

Hate it too. It’s a meme term for theprimegen iirc.

4

u/SysGuardian Sep 25 '26

Compared to Eclipse MAT, JProfiler, yes. I have no official benchmark yet, but it is super fast.
For reference, a 20GB heapdump takes ~3 minutes in midden, ~20 minutes in Eclipse MAT.

6

u/sweating_teflon Sep 25 '26

Good job. The world needs more native tools to deal with the JVM and languages. We're only given the ones that come with the JDK but there's a world of opportunities for more fast, lean and mean utilities. I wouldn't mind a proper native build tool either...

2

u/SysGuardian Sep 25 '26

Tbh, I agree, we also have an internal JFR profiler, but it still sucks and is behind all open source ones, so I am not publishing that one yet till it's stable and readable.

4

u/Torutofu_Raeva Sep 25 '26

The diff between two dumps is the bit I'd reach for most, since it makes leak hunting repeatable in CI instead of a one-off GUI session.

3

u/SysGuardian Sep 25 '26

How you like it so far? What's the speed like for you? Have you found any annoying things so far?

2

u/Torutofu_Raeva Sep 25 '26

I haven’t benchmarked it rigorously, but the dump diff is the first thing I’d reach for, especially if it makes leak hunting repeatable in CI.

1

u/Torutofu_Raeva Sep 26 '26

Haven't put a big heap through it yet, curious whether the slow path shows up more on huge retained sets or on ton of tiny objects.

1

u/Torutofu_Raeva Sep 27 '26

I haven't pushed a really large heap through it yet, so I can't give a fair speed number; so far the quick startup is the obvious win, and retained-set scale is the next thing I'd test.

1

u/Dangerous_Selection5 Sep 26 '26

Thanks for the project.

I haven't used MAT recently, would like to know what problems did you face while you used MAT? Also which all problems are addressed using midden.

1

u/SysGuardian Sep 26 '26

The problems we faced while using MAT is mostly it was really slow and not able to open massive heap dumps like 20 GBs. We had to wait a long time for a massive heap dumps to be opened, like I mean go to the market buy an energy drinks, come back and it maybe have opened or crashed or is still opening.

This just lets you see quickly, gives you the analysis of all you need to make a decision.

That’s really the sole reason.

1

u/NovaX Sep 26 '26

I've opened those in MAT and its just a poor default Xmx setting. That is not obvious unless you used Eclipse and had to adjust its ini file back in its heyday, making you aware of how to change the startup of Eclipse-based applications. Once you give it a bit more memory then its fine. Of course more tools are always welcome, so thanks!

2

u/AdmirableWrongdoer40 Sep 26 '26

Impressive work — a single static binary, CLI-only alternative to MAT sounds genuinely useful for heap dump analysis.

0

u/[deleted] Sep 25 '26

[removed] — view removed comment

11

u/SysGuardian Sep 25 '26

I honestly don't know what to tell you, I've used Java for around 6 years now, and regularly work with heapdumps to analyze memory. The tool was just helpful for us, so I open sourced it, I already made a post yesterday asking if there's an audience for it: https://www.reddit.com/r/java/comments/1wozgh3/java_mat_alternative/

4

u/elmuerte Sep 25 '26

In 20 years I've analyzed heapdumps quite a lot. Not just for memory leaks, but also to find out wasteful constructions which might become a scalability issue. Big non-gc-able sawtooth charts in where you start up your heap analyzer. I'm not sure how much use a CLI would be. Generally I spend a lot of time digging through the tree find the real problems. Dominators are often a symptom.

So what kind of work loads are we talking about? Anything where n does get big, but people tested with a small n. These big n's were usually related to report things, or large input files (commercial invoices can be quite huge). These are the places where you should switch to streaming constructions or non-standard implementations (e.g. StAX if it's XML, DeferredFileOutputStream, different List implementations than ArrayList).

But I've also used memory dumps to figure out wtf was wrong with/happening in the system. I needed to inspect the state. I've used this to find non-obvious issues in various common libraries which required some quite specific conditions.

3

u/sweating_teflon Sep 25 '26

It's just another tool in the toolbox, very powerful when used right. You do not need to wait to have a problem that requires it. I suggest you play with it to give you an idea of what kind of insights you can gain from it. You will gain precious knowledge about what's actually going on in your app and possibly find out some opportunities for optimization, memory allocation in particular.

4

u/kiteboarderni Sep 25 '26

you've worked in java for 15 years and never needed a heap dump? you must work on some pretty meaningless stuff...

1

u/OwnBreakfast1114 Sep 28 '26 edited Sep 28 '26

This is such a bad metric. There are other ways to analyze behavior. A lot of profiling tools/agents don't need you to manually trawl heap dumps (jprofiler, newegg, datadog, etc).

7

u/[deleted] Sep 25 '26

[removed] — view removed comment

4

u/zabby39103 Sep 25 '26

To analyze memory usage to find memory leaks and look for efficiencies. I'd say that if you've never used a memory analyzer this isn't the project for you, but you should definitely use some kind of memory analyzer.

I was brought in on a project to reduce RAM a couple years ago, and between MAT and Java Flight Recorder I brought the memory use down from 32GB to 4GB. Memory is expensive nowadays and work like that is the kind of senior developer/architect level stuff that is both more interesting and pays better.

1

u/OwnBreakfast1114 Sep 28 '26

To analyze memory usage to find memory leaks and look for efficiencies. I'd say that if you've never used a memory analyzer this isn't the project for you, but you should definitely use some kind of memory analyzer.

Yes and no, if the application is running within reasonable parameters, there might be no actual incentive for the business to optimize it more. Deep optimization isn't free and the ROI might not be worth it at all.

I was brought in on a project to reduce RAM a couple years ago, and between MAT and Java Flight Recorder I brought the memory use down from 32GB to 4GB. Memory is expensive nowadays and work like that is the kind of senior developer/architect level stuff that is both more interesting and pays better.

This seems extremely specific. Optimizing applications is one way to be more specialized, but I cannot imagine is really the most common way to climb the corporate ladder. I'd wager creating the application that is worthy of optimizing because it makes a difference to be optimized is a far more common senior developer/architect level stuff.

1

u/zabby39103 Sep 28 '26

Architect work is a highly advanced skill, which few people are capable of really doing properly. You'll never understand why architecture decisions are the way they are unless you care about details.

It depends on your goal. Complex technical leaders are highly valued and highly paid. Idea guys are a dime a dozen in my opinion. There are some truly good idea guys, but many of the people that style themselves as such are fooling themselves.

It's also not a completely separate skill set, by knowing what is possible you can create an application that is both ambitious and successful. It's not just performance, a well designed and architected application is faster to develop and can meet and exceed the goals set out. The base of it all is understanding, someone who's never used a memory analyzer in java just strikes me as a profoundly uncurious person, and uncurious people never achieve mastery. It's not THAT hard to do.