public static void close() {
        NAME_TO_RDD.clear();
        if (null != CONTEXT) {
            CONTEXT.stop();

            // Allow Spark / Hadoop close and finalize() the input streams to its intrenal files.
            // This is a well known problem reported in https://issues.apache.org/jira/browse/SPARK-12216
            System.gc();
        }
        CONTEXT = null;
    }
This is a static cache the prevents Spark from garbage collecting unreferenced RDDs.

@author Marko A. Rodriguez (http://markorodriguez.com)
spark-gremlin/src/main/java/org/apache/tinkerpop/gremlin/spark/structure/Spark.java