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.gs.collections.impl.parallel.SerialParallelPerformanceTest.java

private static void forceGC() {
    IntInterval.oneTo(20).forEach(each -> {
        System.gc();
        try {/*w w w.  j  av  a 2 s  .com*/
            Thread.sleep(100);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
    });
}

From source file:com.slytechs.capture.file.editor.FileEditorImpl.java

public void close() throws IOException {
    try {/*from   w w w. j a  v  a 2s  . co m*/
        this.flush();
    } finally {

        if (this.channel.isOpen()) {
            this.channel.close();
        }

        /*
         * Need to clear the region and run GC as memory mapped buffers may still
         * remain and hold the channel open. This may cause that associated file
         * can not be removed. Running GC seems to help, although officially Sun
         * says that memory mapped buffers are not unmappable and may remain in
         * memory until VM terminates and even beyond that.
         */
        this.edits.clear();
        System.gc();
    }

    edits.close();
}

From source file:com.aliyun.fs.oss.nat.BufferReader.java

public void close() {
    LOG.info("Closing input stream for '" + key + "'.");
    closed = true;//w  w  w . jav a2  s. c  o m
    try {
        if (algorithmVersion == 1) {
            taskEngine.shutdown();
        } else {
            if (in != null) {
                in.close();
                in = null;
            }
        }
    } catch (IOException e) {
        LOG.error("Failed to close input stream.", e);
    } finally {
        System.gc();
        buffer = null;
    }
}

From source file:com.web.server.EJBDeployer.java

@Override
public void run() {
    EJBJarFileListener jarFileListener = new EJBJarFileListener(registry, this.servicesRegistryPort, jarEJBMap,
            jarMDBMap, jms, connectionFactory);
    DefaultFileMonitor fm = new DefaultFileMonitor(jarFileListener);
    FileObject listendir = null;/*from  ww w  .  j a va  2s. co  m*/
    StandardFileSystemManager fsManager = new StandardFileSystemManager();
    String[] dirsToScan = scanDirectory.split(";");
    EJBContext ejbContext;
    try {
        File scanDirFile = new File(dirsToScan[0]);
        File[] scanJarFiles = scanDirFile.listFiles();
        System.out.println("SCANDIRECTORY=" + scanDirectory);
        if (scanJarFiles != null) {
            for (File scanJarFile : scanJarFiles) {
                if (scanJarFile.isFile() && scanJarFile.getAbsolutePath().endsWith(".jar")) {
                    URLClassLoader classLoader = new URLClassLoader(
                            new URL[] { new URL("file:///" + scanJarFile.getAbsolutePath()) },
                            Thread.currentThread().getContextClassLoader());
                    ConfigurationBuilder config = new ConfigurationBuilder();
                    config.addUrls(ClasspathHelper.forClassLoader(classLoader));
                    config.addClassLoader(classLoader);
                    org.reflections.Reflections reflections = new org.reflections.Reflections(config);
                    EJBContainer container = EJBContainer
                            .getInstance("file:///" + scanJarFile.getAbsolutePath(), config);
                    container.inject();
                    Set<Class<?>> cls = reflections.getTypesAnnotatedWith(Stateless.class);
                    Set<Class<?>> clsMessageDriven = reflections.getTypesAnnotatedWith(MessageDriven.class);
                    Object obj;
                    System.gc();
                    if (cls.size() > 0) {
                        ejbContext = new EJBContext();
                        ejbContext.setJarPath(scanJarFile.getAbsolutePath());
                        ejbContext.setJarDeployed(scanJarFile.getName());
                        for (Class<?> ejbInterface : cls) {
                            //BeanPool.getInstance().create(ejbInterface);
                            obj = BeanPool.getInstance().get(ejbInterface);
                            System.out.println(obj);
                            ProxyFactory factory = new ProxyFactory();
                            obj = UnicastRemoteObject.exportObject((Remote) factory.createWithBean(obj),
                                    servicesRegistryPort);
                            String remoteBinding = container.getRemoteBinding(ejbInterface);
                            System.out.println(remoteBinding + " for EJB" + obj);
                            if (remoteBinding != null) {
                                //registry.unbind(remoteBinding);
                                registry.rebind(remoteBinding, (Remote) obj);
                                ejbContext.put(remoteBinding, obj.getClass());
                            }
                            //registry.rebind("name", (Remote) obj);
                        }
                        jarEJBMap.put("file:///" + scanJarFile.getAbsolutePath().replace("\\", "/"),
                                ejbContext);
                    }
                    System.out.println("Class Message Driven" + clsMessageDriven);
                    if (clsMessageDriven.size() > 0) {
                        System.out.println("Class Message Driven");
                        MDBContext mdbContext;
                        ConcurrentHashMap<String, MDBContext> mdbContexts;
                        if (jarMDBMap.get(scanJarFile.getAbsolutePath()) != null) {
                            mdbContexts = jarMDBMap.get(scanJarFile.getAbsolutePath());
                        } else {
                            mdbContexts = new ConcurrentHashMap<String, MDBContext>();
                        }
                        jarMDBMap.put("file:///" + scanJarFile.getAbsolutePath().replace("\\", "/"),
                                mdbContexts);
                        MDBContext mdbContextOld;
                        for (Class<?> mdbBean : clsMessageDriven) {
                            String classwithpackage = mdbBean.getName();
                            System.out.println("class package" + classwithpackage);
                            classwithpackage = classwithpackage.replace("/", ".");
                            System.out.println("classList:" + classwithpackage.replace("/", "."));
                            try {
                                if (!classwithpackage.contains("$")) {
                                    //System.out.println("executor class in ExecutorServicesConstruct"+executorServiceClass);
                                    //System.out.println();
                                    if (!mdbBean.isInterface()) {
                                        Annotation[] classServicesAnnot = mdbBean.getDeclaredAnnotations();
                                        if (classServicesAnnot != null) {
                                            for (int annotcount = 0; annotcount < classServicesAnnot.length; annotcount++) {
                                                if (classServicesAnnot[annotcount] instanceof MessageDriven) {
                                                    MessageDriven messageDrivenAnnot = (MessageDriven) classServicesAnnot[annotcount];
                                                    ActivationConfigProperty[] activationConfigProperties = messageDrivenAnnot
                                                            .activationConfig();
                                                    mdbContext = new MDBContext();
                                                    mdbContext.setMdbName(messageDrivenAnnot.name());
                                                    for (ActivationConfigProperty activationConfigProperty : activationConfigProperties) {
                                                        if (activationConfigProperty.propertyName()
                                                                .equals(MDBContext.DESTINATIONTYPE)) {
                                                            mdbContext.setDestinationType(
                                                                    activationConfigProperty.propertyValue());
                                                        } else if (activationConfigProperty.propertyName()
                                                                .equals(MDBContext.DESTINATION)) {
                                                            mdbContext.setDestination(
                                                                    activationConfigProperty.propertyValue());
                                                        } else if (activationConfigProperty.propertyName()
                                                                .equals(MDBContext.ACKNOWLEDGEMODE)) {
                                                            mdbContext.setAcknowledgeMode(
                                                                    activationConfigProperty.propertyValue());
                                                        }
                                                    }
                                                    if (mdbContext.getDestinationType()
                                                            .equals(Queue.class.getName())) {
                                                        mdbContextOld = null;
                                                        if (mdbContexts.get(mdbContext.getMdbName()) != null) {
                                                            mdbContextOld = mdbContexts
                                                                    .get(mdbContext.getMdbName());
                                                            if (mdbContextOld != null
                                                                    && mdbContext.getDestination().equals(
                                                                            mdbContextOld.getDestination())) {
                                                                throw new Exception(
                                                                        "Only one MDB can listen to destination:"
                                                                                + mdbContextOld
                                                                                        .getDestination());
                                                            }
                                                        }
                                                        mdbContexts.put(mdbContext.getMdbName(), mdbContext);
                                                        Queue queue = (Queue) jms
                                                                .lookup(mdbContext.getDestination());
                                                        Connection connection = connectionFactory
                                                                .createConnection("guest", "guest");
                                                        connection.start();
                                                        Session session;
                                                        if (mdbContext.getAcknowledgeMode() != null
                                                                && mdbContext.getAcknowledgeMode()
                                                                        .equals("Auto-Acknowledge")) {
                                                            session = connection.createSession(false,
                                                                    Session.AUTO_ACKNOWLEDGE);
                                                        } else {
                                                            session = connection.createSession(false,
                                                                    Session.AUTO_ACKNOWLEDGE);
                                                        }
                                                        MessageConsumer consumer = session
                                                                .createConsumer(queue);
                                                        consumer.setMessageListener(
                                                                (MessageListener) mdbBean.newInstance());
                                                        mdbContext.setConnection(connection);
                                                        mdbContext.setSession(session);
                                                        mdbContext.setConsumer(consumer);
                                                        System.out.println("Queue=" + queue);
                                                    } else if (mdbContext.getDestinationType()
                                                            .equals(Topic.class.getName())) {
                                                        if (mdbContexts.get(mdbContext.getMdbName()) != null) {
                                                            mdbContextOld = mdbContexts
                                                                    .get(mdbContext.getMdbName());
                                                            if (mdbContextOld.getConsumer() != null)
                                                                mdbContextOld.getConsumer()
                                                                        .setMessageListener(null);
                                                            if (mdbContextOld.getSession() != null)
                                                                mdbContextOld.getSession().close();
                                                            if (mdbContextOld.getConnection() != null)
                                                                mdbContextOld.getConnection().close();
                                                        }
                                                        mdbContexts.put(mdbContext.getMdbName(), mdbContext);
                                                        Topic topic = (Topic) jms
                                                                .lookup(mdbContext.getDestination());
                                                        Connection connection = connectionFactory
                                                                .createConnection("guest", "guest");
                                                        connection.start();
                                                        Session session;
                                                        if (mdbContext.getAcknowledgeMode() != null
                                                                && mdbContext.getAcknowledgeMode()
                                                                        .equals("Auto-Acknowledge")) {
                                                            session = connection.createSession(false,
                                                                    Session.AUTO_ACKNOWLEDGE);
                                                        } else {
                                                            session = connection.createSession(false,
                                                                    Session.AUTO_ACKNOWLEDGE);
                                                        }
                                                        MessageConsumer consumer = session
                                                                .createConsumer(topic);
                                                        consumer.setMessageListener(
                                                                (MessageListener) mdbBean.newInstance());
                                                        mdbContext.setConnection(connection);
                                                        mdbContext.setSession(session);
                                                        mdbContext.setConsumer(consumer);
                                                        System.out.println("Topic=" + topic);
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            } catch (Exception e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                        }
                    }
                    classLoader.close();
                    System.out.println(scanJarFile.getAbsolutePath() + " Deployed");
                }
            }
        }
        FileSystemOptions opts = new FileSystemOptions();
        FtpFileSystemConfigBuilder.getInstance().setUserDirIsRoot(opts, true);
        fsManager.init();
        for (String dir : dirsToScan) {
            if (dir.startsWith("ftp://")) {
                listendir = fsManager.resolveFile(dir, opts);
            } else {
                listendir = fsManager.resolveFile(dir);
            }
            fm.addFile(listendir);
        }
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    fm.setRecursive(true);
    fm.setDelay(1000);
    fm.start();
}

From source file:com.chtr.tmoauto.webui.CommonFunctions.java

/**
 * This method build and return a webDriver instance by which one can use to control the automation of a specified
 * web browser and platform or Operating System.
 *
 * @param url - main test url/*  w ww.j  a  va  2 s . c  o m*/
 * @param browserType - type of browser to automate
 * @param platform - operating system or platform type
 * @return
 * @return - Instance of WebBrowser
 */
@SuppressWarnings("resource")
public static CommonFunctions buildWebDriver(String url, String browserName, Method method) {
    Annotation[] a = method.getAnnotations();
    String description = null;
    try {
        description = a[0].toString().split("description=")[1].split(", retryAnalyzer=")[0];
    } catch (Exception e) {
    }
    System.gc();
    log.info("");
    log.info("=========================================================");
    log.info("Test: {}", method.getName());
    log.info("Test Description: {}", description);
    log.info("=========================================================");
    WebDriver wd = buildWebDriver(browserName);
    CommonFunctions wDriver = new CommonFunctions(wd);
    log.info("Starting WebDriver: { Browser: {} } { Version: {} } { Platform: {} } ",
            wDriver.getBrowserName().trim(), wDriver.getBrowserVersion().trim(),
            wDriver.discoverPlatform().toString());
    log.info("Navigating to: {}", url);
    wd.get(url);
    return new CommonFunctions(wd);
}

From source file:Fetcher.Fetcher.java

@Deprecated
@Override/*from  ww  w  . j  a  v  a 2  s.  c o m*/
/**
 * run() is deprecated. Use startFetching() instead.
 */
public void run() {
    WebDocument link = null;
    HttpURLConnection connection;
    Proxy p;

    //PreConnfiguration
    //Configure proxy
    //TODO Anonymizer is deprecated. Use in following for warning generation.
    switch (Variables.anonymizerProxyType) {
    case DIRECT:
        p = new Proxy(Proxy.Type.DIRECT,
                new InetSocketAddress(Variables.anonymizerIP, Variables.anonymizerPort));
        break;
    case HTTP:
        p = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(Variables.anonymizerIP, Variables.anonymizerPort));
        break;
    case SOCKS:
        p = new Proxy(Proxy.Type.SOCKS,
                new InetSocketAddress(Variables.anonymizerIP, Variables.anonymizerPort));
        break;
    case NONE:
    default:
        p = null;
        break;
    }

    link = Methods.getNextProfileLink();
    while (link != null && isWorking) {
        //Start fetching ...

        //Check if it should work or not
        Date currentTime = Methods.getCurrentTime();
        if (!currentTime.after(Variables.startTime) || !currentTime.before(Variables.endTime)) {
            try {
                synchronized (t) {
                    getThread().wait(60000); //sleep 60 seconds
                }
            } catch (InterruptedException ex) {
                if (Variables.debug) {
                    Variables.logger.Log(Fetcher.class, Variables.LogType.Error,
                            "Time is not between start and end time and thread is in exception!");
                }
            } finally {
                continue;
            }
        }

        String URL = link.getNextUrl();
        String UA = Methods.getRandomUserAgent(); //Use this UA for refererd or single links.

        //loop for referer
        for (int i = 0; i <= link.getRefererCount(); URL = link.getNextUrl(), i++) {

            if (Variables.debug && Variables.vv) {
                Variables.logger.Log(Fetcher.class, Variables.LogType.Trace,
                        "Fetcher (" + Methods.Colorize(name, Methods.Color.Green) + ") start getting " + URL);
            }

            try {

                //Anonymizer
                if (Variables.anonymizerProxyType == Variables.AnonymizerProxy.NONE) {
                    connection = (HttpURLConnection) new URL(URL).openConnection();
                } else {
                    connection = (HttpURLConnection) new URL(URL).openConnection(p);
                }

                connection.setDoOutput(true);
                connection.setDoInput(true);
                connection.setRequestProperty("User-Agent", UA);
                connection.setRequestProperty("Accept",
                        "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
                connection.setRequestProperty("Accept-Language", "en-US,en;q=0.5");
                connection.setRequestProperty("Accept-Encoding", "gzip, deflated");

                String referer = link.getNextReferrer();
                if (referer != null) {
                    connection.setRequestProperty("Referer", referer);
                    referer = null;
                    System.gc();
                }

                //Send Cookie using user input
                if (!(Variables.Cookie == null || Variables.Cookie.equalsIgnoreCase(""))) {
                    connection.setRequestProperty("Cookie", Variables.Cookie);
                } else if (cookies.getCookieStore().getCookies().size() > 0) { //From referer, there are some cookies
                    connection.setRequestProperty("Cookie", Join(",", cookies.getCookieStore().getCookies()));
                }

                connection.setRequestMethod("GET");

                connection.connect();

                //Get Cookie from response
                getCookies(connection);

                if (connection.getResponseCode() == 200) {
                    //Write to file
                    String outputName = Variables.outputDirectory
                            + link.getOutputName().substring(0, link.getOutputName().lastIndexOf(".")) + i
                            + link.getOutputName().substring(link.getOutputName().lastIndexOf("."));

                    //Check extension
                    if (!(outputName.endsWith("html") || outputName.endsWith("htm"))) {
                        outputName += "html";
                    }

                    //get content
                    String html = "";

                    if (connection.getContentEncoding().equalsIgnoreCase("gzip")) {
                        html = IOUtils.toString(new GZIPInputStream(connection.getInputStream()));
                    } else if (connection.getContentEncoding().equalsIgnoreCase("deflate")) {
                        html = IOUtils.toString(new InflaterInputStream(connection.getInputStream()));
                    }

                    FileWriter fw = new FileWriter(outputName);
                    fw.write(html);
                    fw.flush();
                    fw.close();
                } else { //The returned code is not 200.
                    if (Variables.debug) {
                        Variables.logger.Log(Fetcher.class, Variables.LogType.Error,
                                "Fetcher could not download (" + Methods.Colorize(URL, Methods.Color.Red)
                                        + ") in " + name);
                        if (Variables.vv) {
                            Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Server responded ("
                                    + Methods.Colorize(connection.getResponseCode() + " - "
                                            + connection.getResponseMessage(), Methods.Color.Red)
                                    + ") for " + URL);
                        }
                    }
                }

                //Close the connection
                connection.disconnect();

                //Report progress
                Variables.logger.logResult(connection, link);
                Methods.oneFinished();

                if (Variables.debug && Variables.vv) {
                    Variables.logger.Log(Fetcher.class, Variables.LogType.Info,
                            "[+] Done fetching (" + Methods.Colorize(URL, Methods.Color.Red) + "]");
                }

                try {
                    synchronized (t) {
                        t.wait(Methods.getNextRandom() * 1000);
                    }
                } catch (InterruptedException ex) {
                    if (Variables.debug) {
                        Variables.logger.Log(Fetcher.class, Variables.LogType.Error, "Cannot interrupt thread ["
                                + Methods.Colorize(name, Methods.Color.Red) + "]. Interrupted before!");
                    }
                } catch (IllegalArgumentException ex) {
                    if (Variables.debug) {
                        Variables.logger.Log(Fetcher.class, Variables.LogType.Error,
                                "-1 is returned as random number for thread ["
                                        + Methods.Colorize(name, Methods.Color.Red) + "].");
                    }
                }
            } catch (IOException ex) {
                if (Variables.debug) {
                    if (Variables.vv) {
                        Variables.logger.Log(Fetcher.class, Variables.LogType.Error,
                                "Error in fetching [" + Methods.Colorize(URL, Methods.Color.Red)
                                        + "] in fetcher (" + Methods.Colorize(name, Methods.Color.Yellow)
                                        + ") for writing in ("
                                        + Methods.Colorize(link.getOutputName(), Methods.Color.White)
                                        + "). Detail:\r\n" + ex.getMessage());
                    } else {
                        Variables.logger.Log(Fetcher.class, Variables.LogType.Error,
                                "Error in fetching [" + Methods.Colorize(URL, Methods.Color.Red) + "]");
                    }
                }
            } catch (NullPointerException ex) { //Thrown sometimes and make the thread as Dead!
                if (Variables.debug) {
                    if (Variables.vv) {
                        Variables.logger.Log(Fetcher.class, Variables.LogType.Error,
                                "Null pointer occured. Error in fetching ["
                                        + Methods.Colorize(URL, Methods.Color.Red) + "] in fetcher ("
                                        + Methods.Colorize(name, Methods.Color.Yellow) + ") for writing in ("
                                        + Methods.Colorize(link.getOutputName(), Methods.Color.White) + ").");
                    } else {
                        Variables.logger.Log(Fetcher.class, Variables.LogType.Error,
                                "Null pointer occured. Error in fetching ["
                                        + Methods.Colorize(URL, Methods.Color.Red) + "]");
                    }
                }
            }
        }

        //Check size limit and compress ...
        long size = Methods.getFolderSize(Variables.outputDirectory);
        if (size >= Variables.outputSizeLimit) {
            //Deactivate itself by waiting ...
            Variables.state = Variables.microbotState.Compressing;
            Variables.threadController.changeActiveThreads(false, t, Variables.microbotState.Compressing);
        }

        //Check if user terminated program or not
        if (isWorking) {
            link = Methods.getNextProfileLink();
        }
    }

    //Thread finished. (Normally or by force)
    Variables.state = Variables.microbotState.Stopping;
    Variables.threadController.changeActiveThreads(false, t, Variables.microbotState.Stopping);

    //URLs done. This thread finishes its work.
    if (Variables.debug) {
        Variables.logger.Log(Fetcher.class, Variables.LogType.Info,
                "Fetcher (" + Methods.Colorize(name, Methods.Color.Green) + ") finished its work.");
    }

}

From source file:com.okidokiteam.gouken.kernel.CoreVault.java

public synchronized void stop() throws KernelException {
    try {/*from w  w  w. j  a  v a2s. com*/
        LOG.info("Stop hook triggered.");
        if (m_framework != null) {
            BundleContext ctx = m_framework.getBundleContext();
            Bundle systemBundle = ctx.getBundle(0);
            systemBundle.stop();
            m_framework = null;
        }
        System.gc();
        LOG.info("Shutdown complete.");
    } catch (BundleException e) {
        LOG.error("Problem stopping framework.", e);
    }

}

From source file:flex.helpers.NTPHelper.java

/**
 * Solicitar hora y fecha a servidor NTP.
 * //from  w  w  w . java 2s.  c  o  m
 * @param ntpServer Direccin ip del servidor NTP
 * @return
 * @throws NTPHelperException 
 */
public static Date getDateTime(String ntpServer) throws NTPHelperException {
    if (ntpServer == null)
        throw new NTPHelperException(NTPHelperException.ERROR_NTP_EMPTY);
    if (ntpServer.isEmpty())
        throw new NTPHelperException(NTPHelperException.ERROR_NTP_EMPTY);

    Date time = null;
    NTPUDPClient client = new NTPUDPClient();
    client.setDefaultTimeout(NTP_TIMEOUT);

    try {
        client.open();
        InetAddress hostAddr = InetAddress.getByName(ntpServer);
        TimeInfo info = client.getTime(hostAddr);
        time = processResponse(info);

    } catch (UnknownHostException ex) {
        throw new NTPHelperException(NTPHelperException.ERROR_NTP_UNKNOWN_HOST, ex.getCause());

    } catch (SocketException ex) {
        throw new NTPHelperException(NTPHelperException.ERROR_NTP_SOCKET, ex.getCause());

    } catch (IOException ex) {
        throw new NTPHelperException(NTPHelperException.ERROR_NTP_READ, ex.getCause());

    } finally {
        client.close();
        System.gc();
    }

    return time;
}

From source file:epgtools.dumpepgfromts.Main.java

public void start(String[] args) throws org.apache.commons.cli.ParseException {
    final String fileName;
    final Long limit;

    System.out.println("args   : " + dumpArgs(args));

    final Option fileNameOption = Option.builder("f").required().longOpt("tsfile").desc("ts")
            .hasArg().type(String.class).build();

    final Option limitOption = Option.builder("l").required(false).longOpt("limit").desc(
            "??(???????100000000)")
            .hasArg().type(Long.class).build();

    Options opts = new Options();
    opts.addOption(fileNameOption);/*  w w  w. jav a  2  s  .co m*/
    //        opts.addOption(PhysicalChannelNumberOption);
    opts.addOption(limitOption);
    CommandLineParser parser = new DefaultParser();
    CommandLine cl;
    HelpFormatter help = new HelpFormatter();

    try {

        // parse options
        cl = parser.parse(opts, args);

        fileName = cl.getOptionValue(fileNameOption.getOpt());
        if (fileName == null) {
            throw new ParseException("????????");
        }

        Long xl = null;
        try {
            xl = Long.parseUnsignedLong(cl.getOptionValue(limitOption.getOpt()));
        } catch (NumberFormatException e) {
            xl = 10000000L;
        } finally {
            limit = xl;
        }

        LOG.info("Starting application...");
        LOG.info("filename   : " + fileName);
        LOG.info("limit : " + limit);

        FileLoader fl = new FileLoader(new File(fileName), limit);
        fl.load();

        //???
        Set<Channel> ch = fl.getChannels();
        LOG.info("?? = " + ch.size());
        for (Channel c : ch) {
            LOG.info(
                    "***********************************************************************************************************************************************************************************************************");
            LOG.info(c.getString());
            LOG.info(
                    "***********************************************************************************************************************************************************************************************************");
        }

        //            ?
        Set<Programme> p = fl.getProgrammes();
        LOG.info(" = " + p.size());
        for (Programme pg : p) {
            LOG.info(
                    "***********************************************************************************************************************************************************************************************************");
            LOG.info(pg.getString());
            LOG.info(
                    "***********************************************************************************************************************************************************************************************************");
        }

        System.gc();

    } catch (ParseException e) {
        // print usage.
        help.printHelp("My Java Application", opts);
        throw e;
    } catch (FileNotFoundException ex) {
        LOG.fatal("?????", ex);
    }
}

From source file:fi.ni.IFC_ClassModel.java

/**
 * Instantiates a new iF c_ class model.
 * /*from w w w . ja  va 2 s  .  c  o m*/
 * @param model_file
 *            the name of the IFC file to be read in
 * @param entities
 *            the entities
 * @param types
 *            the types
 */
public IFC_ClassModel(String fileName, InputStream inputStream, Map<String, EntityVO> entities,
        Map<String, TypeVO> types, String ifc_model_name) {
    this.entities = entities;
    this.types = types;
    this.ifc_filename = filter_spaces(fileName);
    this.ifc_model_name = ifc_model_name;
    readModel(inputStream);
    mapEntries();
    calculateTheLongestsPathsToTheNode_and_setGlobalIDs();
    createObjectTree();

    for (Map.Entry<Long, Thing> entry : object_buffer.entrySet()) {
        Thing gobject = entry.getValue();
        if (IfcRoot.class.isInstance(gobject)) {
            IfcRoot t = (IfcRoot) gobject;
            Thing tmp = gid_map.put(t.getGlobalId(), t);
            if (tmp != null) {
                has_duplicate_guids = true;
                System.err.println("Duplicate GUID:" + tmp.line_number + " - " + t.line_number);
            }

        }
        if (IfcProject.class.isInstance(gobject)) {
            root = (IfcProject) gobject;
        }
    }
    // Save memory
    linemap.clear();
    linemap = null;
    System.gc();

}