Hacker News new | past | comments | ask | show | jobs | submit login

That's a disproportional response based on just one aspect of whatever solution the OP is working on.

What is so offensive about JVM memory management? Out of interest what is better in that regard?




Java is pretty well know for being a memory hog.

One of the problems is that nearly everything is an object so you end up with a lot of pointers which takes up additional space. Garbage collection isn't free either.

In this case it would have made sense to go with C++ and allocated as much as possible on the stack. It is cheaper memory wise (because you don't have to keep whatever malloc requires around and because they are removed as soon as you are done with it) and it gives better performance too.

For what you can't allocate on the stack, you a smart pointer.

There are of course pitfalls here -- smart pointers (via reference counting) can be slower than garbage collection and they have trouble dealing with cycles. You may also have to take special care if they are shared across threads.


Please cite some references on it being a memory hog, and in relation to what?

Using C++ makes the assumption that the developer can manage memory a lot better than the JVM. Especially when said developer(s) are developing high level business or web applications for example. And do you really expect developers to spend time writing code that manages memory as opposed to shipping functionality.

I don't know if you have used Java, although I get the impression that you've written C++ programs. You shouldn't be so hasty in pinning your colours to the mast so aggressively over a language. As many people on HN have pointed out it's not the language, but what you do with it that counts.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: