Is there any way to persuade the JVM to completely skip all finalization processes?
In a word No.
But unless a large proportion of your objects have finalize
methods and/or the finalize
methods are particularly expensive, I think that they are unlikely to make GC "very slow". I expect the problem is something else.
I suggest that you turn on GC logging to try and get a better picture of what is actually happening.
But I also agree, that refactoring the code to get rid of the finalize()
methods would probably be a good thing in the long run. (There are very few situations where using finalize
is genuinely the best solution.)
UPDATE - your new evidence is pretty convincing, though not a proof!.
I do not have the power to demand a refactor.
Then, I suggest you place the evidence at the feet of the people who do :-).
Alternatively, you could add an exception handler to the suspect finalize
methods to see if they are throwing exceptions. (And if they are, then change them to avoid the exceptions being thrown ...)
But the bottom line is that if finalization is the real cause of your performance problems then the best (and probably the only) way to cure them is to change the code.