Truly zero garbage collections? Really?
If so, I would suggest one of two options:
- Use a real-time JVM. There are options for managing nearly everything that separates general applications from soft to hard real-time systems.
- Think very seriously about just allocating far more memory than you'll need during a particular run. This isn't a sophisticated solution but if you have the memory available, try allocating 10 times more than you expect to need in your core footprint. It might just work and, you'll have to admit, RAM is cheaper than software engineering labor.
EDIT much later:
It just occurred to me that you should consider allocating your byte array statically. I.e., something like this:
/** Byte arrays that you absolutely have to keep. */
public class KeepForever {
/** Note that I make no claims about thread safety in this simple example. */
public static byte [] keepMe = new byte[100];
};
// Much later in example code ....
/** This should always succeed. No worries about garbage collection. */
public void setMe(int index, byte newByte) {
// Admittedly, this defeats several principles of OOD but it makes
// the point about the syntax.
KeepForever.keepMe[index] = newByte;
}