javamemorymemory-managementgarbage-collectiongarbage

How is it possible to avoid making garbage in Java?


As I know, Java does not have any method for managing memory, because the whole memory management is done by the built in automatically running garbage collector, which might be a little bit inefficient in some cases.

http://www.coralblocks.com/

I have found this website, which tells that they are making a java tools and libraries which works without making any garbage at all. I would like to get some kind of logical explanation about how could it be possible.


Solution

  • In fact, the article about CoralFIX says:

    Zero Garbage: All Coral Blocks components produce zero garbage for the GC in the critical path.

    That's not the same as saying zero garbage at all. And it is achievable (for Coral) only in a relatively small class of applications; i.e. message-based systems where you can do all of the work by in-place matching on the bytes in a message buffer. As soon as you need to need to use normal data structures or (most) standard library classes you will be generating objects.

    And ...

    At Coral Blocks we use Java as a syntax language.

    In other words, Coral Blocks application programmers don't write Java code!


    Is it possible to write your code to do the same thing?

    In theory Yes, but in practice probably No. You would need to replace so much of the functionality of the Java SE libraries (and 3rd party libraries) that you would be better off writing your application1 in a different programming language.

    1 - I guess, if your application was simple and had minimal Java SE and external library dependencies, then it would be feasible to do it. But few non-trivial applications are like that.