Memory Management and performance in Java vs CPP

Hi There,

I would like to know which language among Java and C++ has better memory Management feature, Also which among these two languages is faster in terms of performance and speed?

Java is an interpreted, garbage collected language, so in theory you can always write code that executes faster in C++.

Memory is managed in Java, it’s garbage collected, ipso facto it has better memory management (by definition).

This question seems to come up regularly and, apologies, but it’s a bad question which doesn’t have an answer. Define “better” and “faster” and “performance”: in what context?

C++ is a general-purpose programming language, it introduced the concept of object-oriented programming in the C language, hence it is termed as the C language with classes by many. Java was developed with a goal of having lesser implementation dependencies as possible.

To answer your question, In terms of memory management in C++, the programmer has to manage the memory manually with the use of the operators. Java supports Garbage collection and ha automatic memory management.

CPP creates the binary file during compilation so the execution time is lesser as opposed to Java’s binary file that generates during the runtime. As a result CPP is faster.

Refer here for more information.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.