Steak Inside is a burger item made with a large piece of chicken, cheese and other things. I am a big fan of it. Ah, this is not our today’s topic. Today we will discuss about what is inside Java ? How everything happens inside Java ? If you are familiar with Java then you have already know how Java application starts. From method, main public static void main(String args[]){// Rest of instructions here} And in memory it becomes, ** Red mark space is reserved for method. main() Application starts running within a thread by default. Java uses stack memory ( **green marked** ) to handle this.Lets declare a variable of primitive type, int x;int a; It will look like, Means and will take place in method’s memory. That’s why you can’t access local variables of a method from another method. x a main() Now if we call another method from main method such as, public static void main(String args[]){check();} public static void check(){ } Now what will happen ? Any idea ? Ok. This is the inside picture. Different space will be allocated for method. check() Assume we have a class named , lets have an instance of it in method. Book check() public static void main(String args[]){check();} public static void check(){Book b = new Book();} So it will create an instance in heap memory and keep a reference in method’s memory. check() Java puts primitive types directly in local memory but objects in heap and keep a reference to it in method memory. If we declare c and assign to ` ` it will create a reference to ` `’s object. So if you change anything of ` `, ` ` value will be updated too. Because everything you pass in Java other than method parameters are pass by reference. Method parameters are pass by value. Book b c c = b; b c b After completing execution of the method ` ` automatically it will be removed from stack as well as all references. check() Well, one thread is not enough for us, we need another thread. public static void check(){Thread t = new Thread(){public void run(){background();}};t.start();} public static void background(){ } And this will happen at memory level. As we are running a different thread so it will create a different stack to handle everything of it such as ` ` method in thread 2 stack. As it has been called from second thread. background() If you are a Java fan then you may know that ` ` is immutable in Java. Immutable means you can’t modify it after creation. One of the reason of it is to save memory space. How ? String We have a ` ` variable ` ` in ` ` method having value ` ` and creates a memory space in , then we have declared ` ` having same value ` `. Now it won’t create another ` ` in String Pool rather get a reference to it. If you concat another value lets say it will create a new instance and take memory in String Pool if it’s not exists. When method execution complete only references will be removed not the object. String p1 check() abcd String Pool p2 abcd abcd efg Do you know how ` ` operator and ` ` differs in Java ? ` ` checks for references but ` ` method checks value. == equals() == equals Now you may want to know how Garbage Collector ( GC ) cleans memory. Ok, it looks for unreferenced objects in heap and if found any GC removes it from memory. Within this lookup JVM pauses the application from execution (Pause The World). As this cleanup takes very minimal time we don’t realise it. But if the memory allocation is huge then this pause may affect your application and application may run slowly. And it’s the reason people developed instead of using . Note that ScyllaDB is written in C++. ScyllaDB Cassandra That’s all for today, See you again.