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.gitblit.wicket.pages.BasePage.java

protected void setupPage(String repositoryName, String pageName) {
    add(new Label("title", getPageTitle(repositoryName)));
    getBottomScriptContainer();//  www  . ja va  2s.  co m
    String rootLinkUrl = app().settings().getString(Keys.web.rootLink,
            urlFor(GitBlitWebApp.get().getHomePage(), null).toString());
    ExternalLink rootLink = new ExternalLink("rootLink", rootLinkUrl);
    WicketUtils.setHtmlTooltip(rootLink, app().settings().getString(Keys.web.siteName, Constants.NAME));
    add(rootLink);

    // Feedback panel for info, warning, and non-fatal error messages
    add(new FeedbackPanel("feedback"));

    add(new Label("gbVersion", "v" + Constants.getVersion()));
    if (app().settings().getBoolean(Keys.web.aggressiveHeapManagement, false)) {
        System.gc();
    }
}

From source file:com.CloudRecognition.CloudReco.java

@Override
protected void onDestroy() {
    Log.d(LOGTAG, "onDestroy");
    super.onDestroy();

    try {//  ww w. j  a  va  2  s .com
        vuforiaAppSession.stopAR();
    } catch (SampleApplicationException e) {
        Log.e(LOGTAG, e.getString());
    }

    System.gc();
}

From source file:com.bayesforecast.ingdat.vigsteps.vigmake.VigMakeStep.java

/**
 * This method is called by PDI once the step is done processing. 
 * /*from  w w  w  .  j a  v  a  2 s  .c o m*/
 * The dispose() method is the counterpart to init() and should release any resources
 * acquired for step execution like file handles or database connections.
 * 
 * The meta and data implementations passed in can safely be cast
 * to the step's respective implementations. 
 * 
 * It is mandatory that super.dispose() is called to ensure correct behavior.
 * 
 * @param smi    step meta interface implementation, containing the step settings
 * @param sdi   step data interface implementation, used to store runtime information
 */
public void dispose(StepMetaInterface smi, StepDataInterface sdi) {

    ((VigMakeStepData) sdi).items.clear();
    super.dispose(smi, sdi);
    System.gc();
}

From source file:eu.nubomedia.nubomedia_kurento_health_communicator_android.kc_and_communicator.util.FileUtils.java

public static void DownloadFromUrl(final String media, final String messageId, final Context ctx,
        final ImageView container, final Object object, final String timelineId, final String localId,
        final Long fileSize) {

    new AsyncTask<Void, Void, Boolean>() {
        private boolean retry = true;
        private Bitmap imageDownloaded;
        private BroadcastReceiver mDownloadCancelReceiver;
        private HttpGet job;
        private AccountManager am;
        private Account account;
        private String authToken;

        @Override// ww  w.j  av  a 2s. c o  m
        protected void onPreExecute() {
            IntentFilter downloadFilter = new IntentFilter(ConstantKeys.BROADCAST_CANCEL_PROCESS);
            mDownloadCancelReceiver = new BroadcastReceiver() {
                @Override
                public void onReceive(Context context, Intent intent) {
                    String localIdToClose = (String) intent.getExtras().get(ConstantKeys.LOCALID);
                    if (localId.equals(localIdToClose)) {
                        try {
                            job.abort();
                        } catch (Exception e) {
                            log.debug("The process was canceled");
                        }
                        cancel(false);
                    }
                }
            };

            // registering our receiver
            ctx.getApplicationContext().registerReceiver(mDownloadCancelReceiver, downloadFilter);
        }

        @Override
        protected void onCancelled() {
            File file1 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_JPG);
            File file2 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_3GP);

            if (file1.exists()) {
                file1.delete();
            }
            if (file2.exists()) {
                file2.delete();
            }

            file1 = null;
            file2 = null;
            System.gc();
            try {
                ctx.getApplicationContext().unregisterReceiver(mDownloadCancelReceiver);
            } catch (Exception e) {
                log.debug("Receriver unregister from another code");
            }

            for (int i = 0; i < AppUtils.getlistOfDownload().size(); i++) {
                if (AppUtils.getlistOfDownload().get(i).equals(localId)) {
                    AppUtils.getlistOfDownload().remove(i);
                }
            }

            DataBasesAccess.getInstance(ctx.getApplicationContext()).MessagesDataBaseWriteTotal(localId, 100);

            Intent intent = new Intent();
            intent.setAction(ConstantKeys.BROADCAST_DIALOG_DOWNLOAD_FINISH);
            intent.putExtra(ConstantKeys.LOCALID, localId);
            ctx.sendBroadcast(intent);

            if (object != null) {
                ((ProgressDialog) object).dismiss();
            }
        }

        @Override
        protected Boolean doInBackground(Void... params) {
            try {
                File file1 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_JPG);
                File file2 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_3GP);
                // firt we are goint to search the local files
                if ((!file1.exists()) && (!file2.exists())) {
                    account = AccountUtils.getAccount(ctx.getApplicationContext(), false);
                    am = (AccountManager) ctx.getSystemService(Context.ACCOUNT_SERVICE);
                    authToken = ConstantKeys.STRING_DEFAULT;
                    authToken = am.blockingGetAuthToken(account, ctx.getString(R.string.account_type), true);

                    MessagingClientService messageService = new MessagingClientService(
                            ctx.getApplicationContext());

                    URL urlObj = new URL(Preferences.getServerProtocol(ctx), Preferences.getServerAddress(ctx),
                            Preferences.getServerPort(ctx), ctx.getString(R.string.url_get_content));

                    String url = ConstantKeys.STRING_DEFAULT;
                    url = Uri.parse(urlObj.toString()).buildUpon().build().toString() + timelineId + "/"
                            + messageId + "/" + "content";

                    job = new HttpGet(url);
                    // first, get free space
                    FreeUpSpace(ctx, fileSize);
                    messageService.getContent(authToken, media, messageId, timelineId, localId, false, false,
                            fileSize, job);
                }

                if (file1.exists()) {
                    imageDownloaded = decodeSampledBitmapFromPath(file1.getAbsolutePath(), 200, 200);
                } else if (file2.exists()) {
                    imageDownloaded = ThumbnailUtils.createVideoThumbnail(file2.getAbsolutePath(),
                            MediaStore.Images.Thumbnails.MINI_KIND);
                }

                if (imageDownloaded == null) {
                    return false;
                }
                return true;
            } catch (Exception e) {
                deleteFiles();
                return false;
            }
        }

        @Override
        protected void onPostExecute(Boolean result) {
            // We have the media
            try {
                ctx.getApplicationContext().unregisterReceiver(mDownloadCancelReceiver);
            } catch (Exception e) {
                log.debug("Receiver was closed on cancel");
            }

            if (!(localId.contains(ConstantKeys.AVATAR))) {
                for (int i = 0; i < AppUtils.getlistOfDownload().size(); i++) {
                    if (AppUtils.getlistOfDownload().get(i).equals(localId)) {
                        AppUtils.getlistOfDownload().remove(i);
                    }
                }

                DataBasesAccess.getInstance(ctx.getApplicationContext()).MessagesDataBaseWriteTotal(localId,
                        100);

                Intent intent = new Intent();
                intent.setAction(ConstantKeys.BROADCAST_DIALOG_DOWNLOAD_FINISH);
                intent.putExtra(ConstantKeys.LOCALID, localId);
                ctx.sendBroadcast(intent);
            }

            if (object != null) {
                ((ProgressDialog) object).dismiss();
            }

            // Now the only container could be the avatar in edit screen
            if (container != null) {
                if (imageDownloaded != null) {
                    container.setImageBitmap(imageDownloaded);
                } else {
                    deleteFiles();
                    imageDownloaded = decodeSampledBitmapFromResource(ctx.getResources(),
                            R.drawable.ic_error_loading, 200, 200);
                    container.setImageBitmap(imageDownloaded);
                    Toast.makeText(ctx.getApplicationContext(),
                            ctx.getApplicationContext().getText(R.string.donwload_fail), Toast.LENGTH_SHORT)
                            .show();
                }
            } else {
                showMedia(localId, ctx, (ProgressDialog) object);
            }

        }

        private void deleteFiles() {
            File file1 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_JPG);
            File file2 = new File(FileUtils.getDir(), localId + ConstantKeys.EXTENSION_3GP);
            if (file1.exists()) {
                file1.delete();
            }
            if (file2.exists()) {
                file2.delete();
            }
        }

    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}

From source file:com.plugin.camera.ForegroundCameraLauncher.java

/**
 * Called when the camera view exits./*  w ww .j a v  a  2 s  .  co m*/
 *
 * @param requestCode
 *            The request code originally supplied to
 *            startActivityForResult(), allowing you to identify who this
 *            result came from.
 * @param resultCode
 *            The integer result code returned by the child activity through
 *            its setResult().
 * @param intent
 *            An Intent, which can return result data to the caller (various
 *            data can be attached to Intent "extras").
 */
public void onActivityResult(int requestCode, int resultCode, Intent intent) {

    // If image available
    if (resultCode == Activity.RESULT_OK) {
        try {
            // Create an ExifHelper to save the exif data that is lost
            // during compression
            ExifHelper exif = new ExifHelper();
            exif.createInFile(
                    getTempDirectoryPath(this.cordova.getActivity().getApplicationContext()) + "/Pic.jpg");
            exif.readExifData();

            // Read in bitmap of captured image
            Bitmap bitmap;
            try {
                bitmap = android.provider.MediaStore.Images.Media
                        .getBitmap(this.cordova.getActivity().getContentResolver(), imageUri);
            } catch (FileNotFoundException e) {
                Uri uri = intent.getData();
                android.content.ContentResolver resolver = this.cordova.getActivity().getContentResolver();
                bitmap = android.graphics.BitmapFactory.decodeStream(resolver.openInputStream(uri));
            }

            bitmap = scaleBitmap(bitmap);

            // Create entry in media store for image
            // (Don't use insertImage() because it uses default compression
            // setting of 50 - no way to change it)
            ContentValues values = new ContentValues();
            values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, "image/jpeg");
            Uri uri = null;
            try {
                uri = this.cordova.getActivity().getContentResolver()
                        .insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
            } catch (UnsupportedOperationException e) {
                LOG.d(LOG_TAG, "Can't write to external media storage.");
                try {
                    uri = this.cordova.getActivity().getContentResolver()
                            .insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
                } catch (UnsupportedOperationException ex) {
                    LOG.d(LOG_TAG, "Can't write to internal media storage.");
                    this.failPicture("Error capturing image - no media storage found.");
                    return;
                }
            }
            //This if block is added to the plugin to solve the issue which was saving portrait images in landscape with -90 degree rotetion
            if (intent.getBooleanExtra("portrait", false)) {
                Matrix matrix = new Matrix();
                matrix.preRotate(90);
                try {
                    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
                            true);
                } catch (Exception e) {
                    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth() / 2, bitmap.getHeight() / 2,
                            matrix, true);
                    e.printStackTrace();
                }
            }

            // Add compressed version of captured image to returned media
            // store Uri
            OutputStream os = this.cordova.getActivity().getContentResolver().openOutputStream(uri);
            bitmap.compress(Bitmap.CompressFormat.JPEG, this.mQuality, os);
            os.close();

            // Restore exif data to file
            exif.createOutFile(getRealPathFromURI(uri, this.cordova));
            exif.writeExifData();

            // Send Uri back to JavaScript for viewing image
            this.callbackContext.success(getRealPathFromURI(uri, this.cordova));

            bitmap.recycle();
            bitmap = null;
            System.gc();

            checkForDuplicateImage();
        } catch (IOException e) {
            e.printStackTrace();
            this.failPicture("Error capturing image.");
        }
    }

    // If cancelled
    else if (resultCode == Activity.RESULT_CANCELED) {
        this.failPicture("Camera cancelled.");
    }

    // If something else
    else {
        this.failPicture("Did not complete!");
    }
}

From source file:org.mariotaku.twidere.util.httpclient.HttpClientImpl.java

@Override
public twitter4j.http.HttpResponse request(final twitter4j.http.HttpRequest req) throws TwitterException {
    try {/*  w w  w  . ja v  a  2  s  . c om*/
        HttpRequestBase commonsRequest;

        final HostAddressResolver resolver = conf.getHostAddressResolver();
        final String url_string = req.getURL();
        final URI url_orig;
        try {
            url_orig = new URI(url_string);
        } catch (final URISyntaxException e) {
            throw new TwitterException(e);
        }
        final String host = url_orig.getHost(), authority = url_orig.getAuthority();
        final String resolved_host = resolver != null ? resolver.resolve(host) : null;
        final String resolved_url = !isEmpty(resolved_host)
                ? url_string.replace("://" + host, "://" + resolved_host)
                : url_string;

        if (req.getMethod() == RequestMethod.GET) {
            commonsRequest = new HttpGet(resolved_url);
        } else if (req.getMethod() == RequestMethod.POST) {
            final HttpPost post = new HttpPost(resolved_url);
            // parameter has a file?
            boolean hasFile = false;
            final HttpParameter[] params = req.getParameters();
            if (params != null) {
                for (final HttpParameter parameter : params) {
                    if (parameter.isFile()) {
                        hasFile = true;
                        break;
                    }
                }
                if (!hasFile) {
                    if (params.length > 0) {
                        post.setEntity(new UrlEncodedFormEntity(params));
                    }
                } else {
                    final MultipartEntity me = new MultipartEntity();
                    for (final HttpParameter parameter : params) {
                        if (parameter.isFile()) {
                            final ContentBody body = new FileBody(parameter.getFile(),
                                    parameter.getContentType());
                            me.addPart(parameter.getName(), body);
                        } else {
                            final ContentBody body = new StringBody(parameter.getValue(),
                                    "text/plain; charset=UTF-8", Charset.forName("UTF-8"));
                            me.addPart(parameter.getName(), body);
                        }
                    }
                    post.setEntity(me);
                }
            }
            post.getParams().setBooleanParameter(CoreProtocolPNames.USE_EXPECT_CONTINUE, false);
            commonsRequest = post;
        } else if (req.getMethod() == RequestMethod.DELETE) {
            commonsRequest = new HttpDelete(resolved_url);
        } else if (req.getMethod() == RequestMethod.HEAD) {
            commonsRequest = new HttpHead(resolved_url);
        } else if (req.getMethod() == RequestMethod.PUT) {
            commonsRequest = new HttpPut(resolved_url);
        } else
            throw new TwitterException("Unsupported request method " + req.getMethod());
        final Map<String, String> headers = req.getRequestHeaders();
        for (final String headerName : headers.keySet()) {
            commonsRequest.addHeader(headerName, headers.get(headerName));
        }
        String authorizationHeader;
        if (req.getAuthorization() != null
                && (authorizationHeader = req.getAuthorization().getAuthorizationHeader(req)) != null) {
            commonsRequest.addHeader("Authorization", authorizationHeader);
        }
        if (!isEmpty(resolved_host) && !resolved_host.equals(host)) {
            commonsRequest.addHeader("Host", authority);
        }

        final ApacheHttpClientHttpResponseImpl res;
        try {
            res = new ApacheHttpClientHttpResponseImpl(client.execute(commonsRequest), conf);
        } catch (final IllegalStateException e) {
            throw new TwitterException("Please check your API settings.", e);
        } catch (final NullPointerException e) {
            // Bug http://code.google.com/p/android/issues/detail?id=5255
            throw new TwitterException("Please check your APN settings, make sure not to use WAP APNs.", e);
        } catch (final OutOfMemoryError e) {
            // I don't know why OOM thown, but it should be catched.
            System.gc();
            throw new TwitterException("Unknown error", e);
        }
        final int statusCode = res.getStatusCode();
        if (statusCode < OK || statusCode > ACCEPTED)
            throw new TwitterException(res.asString(), req, res);
        return res;
    } catch (final IOException e) {
        throw new TwitterException(e);
    }
}

From source file:com.imagelake.control.UserDAOImp.java

@Override
public User searchPassword(String pw, int uid) {
    System.out.println(pw + "  " + uid);
    User user = null;// w  ww .j a  v  a2s.c  om
    try {
        String sql = "SELECT * FROM user WHERE user_id=? AND password=?";
        Connection con = DBFactory.getConnection();
        PreparedStatement ps = con.prepareStatement(sql);
        ps.setInt(1, uid);
        ps.setString(2, pw);
        ResultSet rs = ps.executeQuery();

        while (rs.next()) {
            user = new User();
            System.out.println(rs.getInt(1));
            System.out.println(rs.getString(6));
            user.setUser_id(rs.getInt(1));
            user.setUser_name(rs.getString(2));
            user.setFirst_name(rs.getString(3));
            user.setLast_name(rs.getString(4));
            user.setEmail(rs.getString(5));
            user.setPassword(rs.getString(6));
            user.setStreet_add_1(rs.getString(7));
            user.setStreet_add_2(rs.getString(8));
            user.setCity(rs.getString(9));
            user.setState_province(rs.getString(10));
            user.setZip_postal_code(rs.getString(11));
            user.setPhone(rs.getString(12));
            user.setFax(rs.getString(13));
            user.setCom_name(rs.getString(14));
            user.setWebsite(rs.getString(15));
            user.setCom_phone(rs.getString(16));
            user.setCom_fax(rs.getString(17));
            user.setDate(rs.getString(18));
            user.setState(rs.getInt(19));
            user.setBilling_country(rs.getInt(20));
            user.setUser_type(rs.getInt(21));
            user.setCurrent_country_id(rs.getInt(22));
            System.out.println("user");
            System.gc();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return user;
}

From source file:com.xilinx.kintex7.MainScreen.java

public void initialize(LandingPage l, String imgName, int mode) {
    lp = l;/*from  w w w.j  a  v  a2s.  c om*/
    blockDiagram = Toolkit.getDefaultToolkit()
            .getImage(getClass().getResource("/com/xilinx/kintex7/" + imgName));
    led1 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/green.png"));
    led2 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/ledoff.png"));
    led3 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/gui/red.png"));
    this.mode = mode;
    setModeText(mode);
    dataMismatch0 = dataMismatch2 = errcnt0 = errcnt1 = false;
    di = null;
    di = new DriverInfo();
    di.init(mode);
    int ret = di.get_PCIstate();

    //ret = di.get_PowerStats();
    test1_option = DriverInfo.ENABLE_LOOPBACK;
    test2_option = DriverInfo.ENABLE_LOOPBACK;
    // create a new jframe, and pack it
    frame = new JFrame("Kintex-7 Connectivity TRD Control & Monitoring Interface");
    frame.pack();
    frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    final int m = mode;
    frame.addWindowListener(new WindowAdapter() {
        @Override
        public void windowClosing(WindowEvent e) {
            // check if tests are running or not
            if ((testStarted || testStarted1)
                    && ((m != LandingPage.APPLICATION_MODE) || (m != LandingPage.APPLICATION_MODE_P2P))) {
                int confirmed = JOptionPane.showConfirmDialog(null,
                        "This will stop the tests and uninstall the drivers. Do you want to continue?", "Exit",
                        JOptionPane.YES_NO_OPTION);
                if (confirmed == JOptionPane.YES_OPTION) {
                    if (testStarted) {
                        di.stopTest(0, test1_option, Integer.parseInt(t1_psize.getText()));
                        testStarted = false;
                    }
                    if (testStarted1) {
                        di.stopTest(1, test2_option, Integer.parseInt(t2_psize.getText()));
                        testStarted1 = false;
                    }

                    timer.cancel();
                    textArea.removeAll();
                    di.flush();
                    di = null;
                    System.gc();
                    lp.uninstallDrivers();
                    showDialog("Removing Device Drivers...Please wait...");
                }
            } else {
                int confirmed = JOptionPane.showConfirmDialog(null,
                        "This will Uninstall the drivers. Do you want to continue?", "Exit",
                        JOptionPane.YES_NO_OPTION);
                if (confirmed == JOptionPane.YES_OPTION) {
                    timer.cancel();
                    textArea.removeAll();
                    di.flush();
                    di = null;
                    System.gc();
                    lp.uninstallDrivers();
                    showDialog("Removing Device Drivers...Please wait...");
                }
            }
        }
    });

    // make the frame half the height and width
    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    height = screenSize.height;
    width = screenSize.width;

    minWidth = 1000;
    minHeight = 700;
    minFrameWidth = 1024;
    minFrameHeight = 745;

    reqHeight = 745;
    if (width < 1280)
        reqWidth = 1024;
    else if (width == 1280)
        reqWidth = 1280;
    else if (width < 1600) {
        reqWidth = width - (width * 4) / 100;
        reqHeight = height - (height * 3) / 100;
    } else {
        reqWidth = reqHeight = height = height - (height * 10) / 100;
    }

    frame.setSize(new Dimension(minFrameWidth, minFrameHeight));
    frame.setResizable(true);
    frame.addComponentListener(new ComponentListener() {

        @Override
        public void componentResized(ComponentEvent ce) {
            frame.setSize(new Dimension(Math.max(minFrameWidth, frame.getWidth()),
                    Math.max(minFrameHeight, frame.getHeight())));
        }

        @Override
        public void componentMoved(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentShown(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public void componentHidden(ComponentEvent ce) {
            //throw new UnsupportedOperationException("Not supported yet.");
        }
    });
    frame.setVisible(true);

    frame.setIconImage(
            Toolkit.getDefaultToolkit().getImage(getClass().getResource("/com/xilinx/kintex7/icon.png")));
    // center the jframe on screen
    frame.setLocationRelativeTo(null);

    frame.setContentPane(createContentPane());

    keyWord = new SimpleAttributeSet();
    StyleConstants.setForeground(keyWord, Color.RED);

    StyleConstants.setBold(keyWord, true);

    logStatus = new SimpleAttributeSet();
    StyleConstants.setForeground(logStatus, Color.BLACK);
    StyleConstants.setBold(logStatus, true);

    if ((mode == LandingPage.APPLICATION_MODE) || (mode == LandingPage.APPLICATION_MODE_P2P)) {
        testStarted = testStarted1 = true;
    }

    if (mode == LandingPage.PERFORMANCE_MODE_RAW) {
        t1_o1.setSelected(true);
        t1_o2.setEnabled(false);
        t1_o3.setEnabled(false);
        t2_o2.setEnabled(false);
        t2_o3.setEnabled(false);
    }
    if (mode == LandingPage.PERFORMANCE_MODE_RAW_DV) {
        t1_o2.setEnabled(false);
        t1_o3.setEnabled(false);
        t2_o2.setEnabled(false);
        t2_o3.setEnabled(false);
        t1_o1.setSelected(true);
    }

    // initialize max packet size
    ret = di.get_EngineState();
    EngState[] engData = di.getEngState();
    maxpkt0 = engData[0].MaxPktSize;
    minpkt0 = engData[0].MinPktSize;

    minpkt1 = engData[2].MinPktSize;
    maxpkt1 = engData[2].MaxPktSize;

    t1_psize.setText(String.valueOf(maxpkt0));
    t2_psize.setText(String.valueOf(maxpkt1));

    t1_psize.setToolTipText(minpkt0 + "-" + maxpkt0);
    t2_psize.setToolTipText(minpkt1 + "-" + maxpkt1);

    updateLog(di.getPCIInfo().getVersionInfo(), logStatus);
    updateLog("Configuration: " + modeText, logStatus);

    // LED status
    di.get_LedStats();
    lstats = di.getLedStats();
    setLedStats(lstats);

    startTimer();
}

From source file:biomine.bmvis2.Vis.java

public void closeTab(GraphTab t) {
    tabs.remove(t);
    System.gc();
    updateMenuBars();
    Logging.info("ui", "closeTab()");
}

From source file:edu.cmu.cs.lti.util.general.BasicConvenience.java

public static void runAndReportMemoryUsage(String label, Runnable r) {
    System.gc();
    try {/* www.  j  a v a2  s  .  c  o  m*/
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    System.gc();
    long total = Runtime.getRuntime().totalMemory();
    long free = Runtime.getRuntime().freeMemory();
    System.out.println("STARTING " + label);
    System.out.println("Total (JVM): " + total / MB + " MB");
    System.out.println("Free (before): " + free / MB + " MB");
    long used = total - free;
    long usedAtStart = used;
    System.out.println("Used (before): " + used / MB + " MB");
    r.run();
    System.out.println("DONE " + label);
    System.gc();
    try {
        Thread.sleep(10000);
    } catch (InterruptedException e) {
        throw new RuntimeException(e);
    }
    System.gc();

    total = Runtime.getRuntime().totalMemory();
    free = Runtime.getRuntime().freeMemory();
    long nowUsed = total - free;
    System.out.println("Free (after): " + free / MB + " MB");
    System.out.println("Used (after): " + nowUsed / MB + " MB");
    System.out.println("Difference: " + (nowUsed - usedAtStart) / MB + " MB");
}