Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8289231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:27:36+00:00 2026-06-08T12:27:36+00:00

I am testing some JDKs and need to trigger garbage collection multiple times. How

  • 0

I am testing some JDKs and need to trigger garbage collection multiple times. How can I easily do this in a simple program? Examples would be extremely helpful. Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:27:38+00:00Added an answer on June 8, 2026 at 12:27 pm

    See here for a good discussion on garbage collection. You can request that it is run (as noted by previous answers), but it is not a guarantee, so you should not assume too much with the call. Your best option is to create and destroy new objects many, many times. To allow them to be destroyed, create them in a block and close it again. Perhaps something like this:

    for(int i = 0; i < MAX; ++i) {
        {
            Integer i = new Integer(0);
        }
    }
    

    And you could monitor the memory use externally?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I'm testing some CRUD operations in Nhibernate. I have 3 tests in this
I'm testing some legacy code that extends the default php exception object. This code
I am now testing some IPN for our subscription system. from this document https://www.paypal.com/cgi-bin/webscr?cmd=p/acc/ipn-subscriptions-outside
I've got this issue with database locking when I'm testing some threading features I've
So I've been looking around for hours, testing multiple versions, testing some of my
I am unit testing some CRUD operations. My questions are: 1) If I need
I've been testing some stuff with Google maps, and while this code gives me
This problem baffles me. I am testing some Haskell bindings to OpenGL, I create
I'm testing some snippets I found off the web using g++ from MinGW. This
Testing some late static binding and getting this error on line 5: Parse error:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.