Question: Is it possible to force garbage collection in Java, even if it is tricky to do? I know about `System.gc();` and `Runtime.gc();` but they only suggest to do GC. How can I force GC?

Answer: 
If you need to force garbage collection, perhaps you should consider how you're managing resources. Are you creating large objects that persist in memory? Are you creating large objects (e.g., graphics classes) that have a `Disposable` interface and not calling `dispose()` when done with it? Are you declaring something at a class level that you only need within a single method?
I wanted to force gc, because my code was frozen for a long time when it happened. The aim is to smooth the charge, by regularly cause gc.
The solutions listed doesnt forced anything in my environment.

So:

* I request the memory for temporary variable,
* simply, by increments,
* and monitor the memory and stop the operation as soon as gc is triggered.

It works easily but you have to tune.

```html
Runtime rt = Runtime.getRuntime();
double usedMB = (rt.totalMemory() - rt.freeMemory()) / 1024 / 1024;

if (usedMB > 1000) // only when necessary
{
byte[][] for_nothing = new byte[10][];

for (int k = 0; k < 10 ; k ++)
    for_nothing[k] = new byte[100_000_000];
}

System.gc();
Runtime.getRuntime().gc();
Runtime.getRuntime().runFinalization(); 
```