Example usage for java.lang System gc

List of usage examples for java.lang System gc

Introduction

In this page you can find the example usage for java.lang System gc.

Prototype

public static void gc() 

Source Link

Document

Runs the garbage collector in the Java Virtual Machine.

Usage

From source file:com.fizzed.rocker.bin.ConstantPoolMain.java

static public void main(String[] args) throws Exception {
    new ConstantPoolMain().run(args);

    System.out.println("About to exit app. Press any key to continue...");
    System.in.read();//from  w ww  .  j  a va 2s.  co  m

    System.gc();
    System.gc();
    System.gc();
    System.gc();

    System.out.println("-----------------------------");
    System.out.println("Just before exit");
    garbageCollectAndPrintMemory();
}

From source file:com.josescalia.tumblr.app.Bootstrap.java

public static void main(String[] args) {
    final Bootstrap app = new Bootstrap();

    //initialize splashScreen
    final ApplicationSplash splash = new ApplicationSplash();
    splash.setTitle("Tumblr Rss Image Viewer");
    splash.setSplashImage(app.getSplashImage());
    splash.setIconImage(new ImageIcon(splash.getClass().getResource("/icons/tumblr.png")).getImage());
    splash.setVisible(true);/*from  w  ww  . j a v a  2s.  c  o m*/
    //read or write applicationConfig

    new SwingWorker<String, String>() {
        @Override
        protected String doInBackground() throws Exception {
            app.runApp(splash);
            return "Done";
        }

        protected void done() {
            System.gc();
            logger.info("Application Running..");
        }
    }.execute();
}

From source file:MyTerrierClass.java

public static void main(String[] args) throws InterruptedException, IOException {

    System.gc();
    System.setProperty("terrier.home", "/home/manan/Downloads/terrier-4.0");
    System.setProperty("terrier.etc", "/home/manan/Downloads/terrier-4.0/etc");
    System.setProperty("terrier.setup", "/home/manan/Downloads/terrier-4.0/etc/terrier.properties");

    bw = new BufferedWriter(new FileWriter("/home/manan/terrier_trials/myOutput.txt", false));
    bw.write("#######OUTPUT#######");

    List<String> cl = new ArrayList<>();
    cl.add("/home/manan/wiki-small/");
    SimpleFileCollection sf = new SimpleFileCollection(cl, true);

    print("sf list size b4 indexing:" + sf.getFileList().size());

    Indexer indexer = new BlockIndexer("/home/manan/terrier_trials/", ".trial");
    indexer.index(new Collection[] { sf });

    print("sf list size after indexing:" + sf.getFileList().size());
    sf.reset();/*  w ww . java  2s . com*/
    //get document reader
    Reader reader = sf.next().getReader();
    //print all tokens
    Tokeniser tokeniser = Tokeniser.getTokeniser();
    TokenStream ts = tokeniser.tokenise(reader);
    while (ts.hasNext()) {
        System.out.println(ts.next());
    }

    //        Index index = Index.createIndex();
    //        
    //        Manager queryingManager = new Manager(index);
    // 
    //        String query = "name quick";
    //        SearchRequest srq = queryingManager.newSearchRequest("queryID0", query);
    //        srq.addMatchingModel("Matching", "PL2");
    //        queryingManager.runPreProcessing(srq);
    //        queryingManager.runMatching(srq);
    //        queryingManager.runPostProcessing(srq);
    //        queryingManager.runPostFilters(srq);
    //        ResultSet rs = srq.getResultSet();
    //        for(int each : rs.getDocids())
    //            System.out.println("docids: "+ each);

    //        Index index = Index.createIndex();
    //        Lexicon<String> lex = index.getLexicon();
    //        print("lex number of entries: "+lex.numberOfEntries());
    //        String myTerm = "name";
    //        LexiconEntry le = lex.getLexiconEntry(myTerm);
    //        if(le!=null)
    //        {
    //            print(myTerm+" in number of docs: "+le.getDocumentFrequency());
    //            print(myTerm+" occurance times: "+le.getFrequency());
    //        }
    //        else
    //        {
    //            print(myTerm+" not found");
    //        }

    //        Index index = Index.createIndex();
    //        BitPostingIndex inv = (BitPostingIndex) index.getInvertedIndex();
    //        MetaIndex meta = index.getMetaIndex();
    //        Lexicon<String> lex = index.getLexicon();
    //        LexiconEntry le = lex.getLexiconEntry( "name" );
    //        IterablePosting postings = inv.getPostings((BitIndexPointer) le);
    //        while (postings.next() != IterablePosting.EOL) {
    //                String docno = meta.getItem("docno", postings.getId());
    //                System.out.println(docno + " with frequency " + postings.getFrequency());
    //        }

    bw.close();
}

From source file:mx.unam.ecologia.gye.coalescence.app.RunExperiments.java

public static void main(String[] args) {
    BasicConfigurator.configure();//from  ww  w. ja  v a  2  s .  c  o m
    SimulationParameters params = new SimulationParameters(args);
    //loop
    int num_beta = params.getBetaCount();
    int num_k = params.getKCount();
    int num_N = params.getNCount();
    int num_u = params.getUCount();
    PrintWriter pw;

    try {
        File csv = new File(params.getOutput());
        FileOutputStream fout = new FileOutputStream(csv);
        pw = new PrintWriter(fout);
    } catch (Exception ex) {
        pw = new PrintWriter(System.out);
    }
    for (int l = 0; l < num_beta; l++) {
        params.selectBeta(l);
        for (int m = 0; m < num_N; m++) {
            params.selectN(m);
            for (int n = 0; n < num_k; n++) {
                params.selectK(n);
                for (int o = 0; o < num_u; o++) {
                    params.selectU(o);
                    MicrosatelliteExperiment exp = new MicrosatelliteExperiment(params);
                    if (m + n + o == 0) {
                        pw.println(exp.getCSVHeader());
                        pw.flush();
                    }
                    exp.init();
                    exp.run();
                    pw.println(exp.resultsToCSV());
                    pw.flush();
                    System.gc();
                } //for u
            } //for k
        } //for N
    } //for beta
}

From source file:com.matthatem.ai.search.applications.MSASolver.java

public static void main(String[] args) {
    Options options = createOptions();//  w ww  . jav a 2 s  . co m
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        e.printStackTrace();
        System.exit(1);
    }

    MSA msa = createMSAInstance(cmd);
    SearchAlgorithm algo = createSearchAlgorithm(cmd, msa);

    System.gc();

    long t = System.currentTimeMillis();
    SearchResult<MSAState> result = algo.search();
    long td = System.currentTimeMillis();

    result.setAlgorithm(algoString);
    result.setInitialH((int) msa.getHeuristic().getInitH());
    result.setStartTime(t);
    result.setEndTime(td);

    System.out.println(result);
    //System.out.println(msa.alignmentToString());
    System.out.println(msa.alignmentToMSFString());
}

From source file:com.l2jfree.gameserver.util.ModuleTester.java

public static void main(String[] args) throws Exception {
    Config.load();//from   w  w  w  .j  a  va2s  .c  o m
    Config.DATAPACK_ROOT = new File("../l2jfree-datapack");
    //L2DatabaseFactory.getInstance();

    // here comes what you want to test
    //SkillTable.getInstance();
    //HtmCache.getInstance();

    //new WeaponSQLConverter().convert();
    //convertSkills();

    System.gc();
    System.runFinalization();
    Thread.sleep(1000);
}

From source file:edu.ehu.galan.lite.algorithms.ranked.supervised.tfidf.corpus.wikipedia.WikiCorpusBuilder.java

/**
 * Builds a Lucene index containing the Wikipedia data using a wikiExtractor folder with
 * wikipedia articles (no compression), wikiExtractor, the parameters are, the number of words
 * that a document needs to be taken into account (integer), the directory where the Lucene
 * index will be built, the directory where the WikiExtractor files are.
 *
 * @param args/*from   www  . j  a v a  2 s .co  m*/
 */
public static void main(String[] args) {
    WikiCorpusBuilder doc = new WikiCorpusBuilder();
    limit = 700;
    doc.initializeIndex("/home/angel/wikipedia/indexEU700");
    doc.extract(new File("/home/angel/wikipedia/extractedEU"));
    System.gc();

}

From source file:org.reunionemu.jreunion.server.Server.java

/**
 * @param args/*from w  w  w.  ja v  a 2s.c  o  m*/
 * @throws Throwable
 */
public static void main(String[] args) throws Exception {

    context = new ClassPathXmlApplicationContext("classpath*:/META-INF/spring/**/*-context.xml");

    ((AbstractApplicationContext) context).registerShutdownHook();

    //Reference.getInstance().Load();

    Server server = Server.getInstance();

    try {

        //server.database.start();

        //server.fireEvent(server.createEvent(ServerStartEvent.class, server));         

        // modules
        // Load a module by extending it from
        // ClassModule
        // And put the put the parent in the constructor

        System.gc();
        //server.setState(State.RUNNING);
        synchronized (server) {
            server.wait();
        }

    } catch (Exception e) {

        logger.error("Exception", e);

    }
}

From source file:GridFDock.GridFDockRunner.java

public static void main(String[] args) {
    SimpleDateFormat sdf = null;//from   www. j  av a  2s .  com
    String executeTime;
    try {
        System.out.println("*********** Work Started **********");
        System.out.println("###################################################################" + "\n"
                + "# If you used MolGridCal in your work, please cite:               #" + "\n"
                + "#                                                                 #" + "\n"
                + "# Qifeng Bai, PLoS One. 2014 Sep 17;9(9):e107837.                 #" + "\n"
                + "# Download site: https://github.com/MolGridCal/MolGridCal         #" + "\n"
                + "# E-mail (molaical@yeah.net)                                    #" + "\n"
                + "# Blog website (http://molgridcal.blog.163.com).                  #" + "\n"
                + "###################################################################");
        // Create the client.
        jppfClient = new JPPFClient();
        // create a runner instance.
        GridFDockRunner runner = new GridFDockRunner();
        // Create a job
        sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        executeTime = sdf.format(new java.util.Date());
        System.out.println("Executed time is on: " + executeTime);
        runner.executeBlockingJob(jppfClient);
        // JPPFJob job = runner.buildJob();
        // execute a blocking job
        // runner.executeBlockingJob(job);
    } catch (Exception e) {
        System.out.println("get bad results******!");
        e.printStackTrace();
    } finally {
        if (jppfClient != null)
            jppfClient.close();
    }

    executeTime = sdf.format(new java.util.Date());
    System.out.println("The work finished time is on: " + executeTime);
    System.gc();
}

From source file:com.l2jserver.model.template.SkillTemplateConverter.java

public static void main(String[] args) throws SQLException, IOException, ClassNotFoundException, JAXBException {
    Class.forName("com.mysql.jdbc.Driver");

    final File target = new File("data/templates");
    final JAXBContext c = JAXBContext.newInstance(SkillTemplate.class, LegacySkillList.class);
    final Connection conn = DriverManager.getConnection(JDBC_URL, JDBC_USERNAME, JDBC_PASSWORD);

    System.out.println("Generating template XML files...");
    c.generateSchema(new SchemaOutputResolver() {
        @Override/*from  ww  w  .j av  a  2  s.  com*/
        public Result createOutput(String namespaceUri, String suggestedFileName) throws IOException {
            return new StreamResult(new File(target, suggestedFileName));
        }
    });

    try {
        final Unmarshaller u = c.createUnmarshaller();
        final Marshaller m = c.createMarshaller();
        m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
        m.setProperty(Marshaller.JAXB_NO_NAMESPACE_SCHEMA_LOCATION, "skill");
        m.setProperty(Marshaller.JAXB_SCHEMA_LOCATION, "skill ../skill.xsd");

        Collection<File> files = FileUtils.listFiles(new File(LEGACY_SKILL_FOLDER), new String[] { "xml" },
                true);
        for (final File legacyFile : files) {
            LegacySkillList list = (LegacySkillList) u.unmarshal(legacyFile);
            for (final LegacySkill legacySkill : list.skills) {
                SkillTemplate t = fillSkill(legacySkill);
                final File file = new File(target, "skill/" + t.id.getID()
                        + (t.getName() != null ? "-" + camelCase(t.getName()) : "") + ".xml");
                templates.add(t);

                try {
                    m.marshal(t, getXMLSerializer(new FileOutputStream(file)));
                } catch (MarshalException e) {
                    System.err.println(
                            "Could not generate XML template file for " + t.getName() + " - " + t.getID());
                    file.delete();
                }
            }
        }

        System.out.println("Generated " + templates.size() + " templates");

        System.gc();
        System.out.println("Free: " + FileUtils.byteCountToDisplaySize(Runtime.getRuntime().freeMemory()));
        System.out.println("Total: " + FileUtils.byteCountToDisplaySize(Runtime.getRuntime().totalMemory()));
        System.out.println("Used: " + FileUtils.byteCountToDisplaySize(
                Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory()));
        System.out.println("Max: " + FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory()));
    } finally {
        conn.close();
    }
}