February 17, 201510 yr So I noticed one of my scripts was using stupid amounts of RAM, but at the cost of a little CPU usage, I solved it! I present to you... *drumroll* THE ULTIMATE GARBAGE COLLECTOR /* * @author: Valkyr * * This class is a replacement for the default JVM garbage collection. * The factory of GarbageCollectors is used to * create a constant flow of garbage collection. The ArrayList of * GarbageCollectors are like an army which get sent back in time to * destroy the garbage before it's able to harm. * */ import java.util.ArrayList; import java.util.Iterator; public class GarbageCollector { static ArrayList<GarbageCollector> collectors = new ArrayList<GarbageCollector>(); public GarbageCollector() { new Thread(new Runnable() { @Override public void run() { while (true) { GarbageCollector.collectors.add(new GarbageCollector()); // Creates a new GarbageCollector Iterator<GarbageCollector> it = collectors.iterator(); while (it.hasNext()) { GarbageCollector gc = it.next(); // Assign's the GarbageCollector's role try { Thread.sleep(-1); // Sends the GarbageCollector back in time } catch (InterruptedException e) { e.printStackTrace(); } ((GC) gc.getGet().getGC().get().getGet()).gc(); // Activate's the GarbageCollector's internal hardware and eradicates the garbage } } } }).start(); } public GarbageCollector getGet() { return new GarbageCollector(); } public GC getGC() { return new GC(); } public static class GC extends GarbageCollector { /* * The GC. Core of every GarbageCollector. It is vital to fight and defend against the garbage. */ public GC getGet() { return new GC(); } public GarbageCollector get() { return new GarbageCollector(); } public void gc() { Runtime.getRuntime().gc(); // Destroys the garbage. } } } Note: Don't actually use this, I posted it as a joke because I'm bored. Edited February 17, 201510 yr by Valkyr
February 17, 201510 yr Note: Don't actually use this, I posted it as a joke because I'm bored. then why is it under the snippet section lol
February 17, 201510 yr Author then why is it under the snippet section lol Its an old snippet I found lying around from when I was trolling rune-server :P I guess a mod could move it to spam/off-topic
February 17, 201510 yr The ArrayList of* GarbageCollectors are like an army which get sent back in time to* destroy the garbage before it's able to harm.
Create an account or sign in to comment