Why java program always take a minimum memory of 177.7 MB and even though problem is small takes more time to execute.

When I execute some java code in the codechef it always takes 1777.7 Mb of memory and a simple program with 4-5 steps without loop also takes a few seconds.Why?

@nishantlakhara you can refer to below links hope it helps you

2 Likes

Java program always take minimum memory of 177.7 MB may be bcz their is JVM memory involved, And their is another classes loaded on startup .

2 Likes

Short answer: Java is different from the rest.

Long answer: Java is a language which was written with the WORA philosophy in mind (WORA = Write Once Run Anywhere).

This philosophy is only possible if Java applications use some sort of layer which “masks” the operating system the application is running on… Such layer is called JVM - Java Virtual Machine, which takes up a lot of memory to set up and also takes some time to load specific libraries which allow for this sort of “portability over speed efficiency” design choice.

Best,

Bruno

2 Likes


All i can tell you is that using c/c++ is better in most of the cases when compared to java.Of course it is not advisable always…Java takes in a lot of memory and it takes a lot of time for executions also…:slight_smile: