My approach was to create hundred thousand local collections and populate them with random strings, something like this:
SecureRandom random = new Secure
I think this should do the trick ... if you run it long enough:
HashMap map = new HashMap();
for (long i = 0; true; i++) {
for (int j = 0; j < 100; j++) {
String s = "" + j;
map.put(i, s);
}
}
What I'm doing is slowly building up the amount of the non-garbage, while creating a significant amount of garbage at the same time. If this is run until the non-garbage fills nearly all of the heap, the GC will get to a point where the % of time spent garbage collecting exceeds the threshold.