If I know what memory I allocate and When it needs to be freed. Can I disable Garbage collection in Java?
The garbage only triggers when you run out of memory (except the concurrent collectors) If you don't create much garbage and never run out of memory you won't need the GC and it won't run.
Why you would want to do this for an app, I don't know. This technique is used in a high frequency trading, to minimise or avoid the GC, but I don't see the point for an app.
I just want to make the memory requirement of my app <1mb.
This is very hard to do as the environment will use this much to run even a hello world program. Your application can add this much.
I think there has to be an option to disable creating garbage and then collecting it. I don't want to keep garbage at all.
If you don't want to keep garbage then you need a garbage collector. If you do the recycling yourself, you don't need a GC.
Moreover Garbage collection still leaves leaks, so in a regular C program finding leaks is tedious same is the case with Java GC.
The GC doesn't leak in the same way as C program does, memory can always be recovered. In Java a "memory leak" just means any undesirable increase in memory usage.
Let me handle my garbage my self..
No one is stopping you.