Pages

sizeof in java or how much memory is this object going to consume

Introduction

Ever wonder what is the size of an object? How much space does it take up? And where can I find out this info?
 
 
In this post we will try to answer these question. And see what difference does it make if you use primitives vs Objects (for example float vs Float).
 
The code used in this example is available here for you to try out. I ran my code with JDK 21. Feel free to try out other versions and see if makes a difference.  

Identifying which Java thread is consuming the most CPU

I didn’t come up with this. I was shown how to do this by an esteemed college at work. I only tested this on Linux.


Introduction

Most (if not all) productive systems doing anything important will use more than 1 java thread. And when something goes crazy and your cpu usage is on 100%, it is hard to identify which thread(s) is/are causing this. Or so I thought. Until someone smarter than me showed me how it can be done. And here I will show you how to do it and you too can amaze your family and friends with your mad geek skillz.