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 8987299
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:45:22+00:00 2026-06-15T21:45:22+00:00

Java programmers know that JVM runs a Garbage Collector, and System.gc() would just be

  • 0

Java programmers know that JVM runs a Garbage Collector, and System.gc() would just be a suggestion to JVM to run a Garbage Collector. It is not necessarily that if we use System.gc(), it would immediately run the GC.

Please correct me if I misunderstand Java’s Garbage Collector.

Is/are there any other way/s doing memory management other than relying on Java’s Garbage Collector?
If you intend to answer the question by some sort of programming practice that would help managing the memory, please do so.

  • 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-15T21:45:24+00:00Added an answer on June 15, 2026 at 9:45 pm

    The most important thing to remember about Java memory management is "nullify" your reference.

    Only objects that are not referenced are to be garbage collected.

    For example, objects in the following code is never get collected and your memory will be full just to do nothing.

    List objs = new ArrayList();
    for (int i = 0; i  < Integer.MAX_VALUE; i++) objs.add(new Object());

    But if you don’t reference those object … you can loop as much as you like without memory problem.

    List objs = new ArrayList();
    for (int i = 0; i  < Integer.MAX_VALUE; i++) new Object();

    So what ever you do, make sure you remove reference to object to no longer used (set reference to null or clear collection).

    When the garbage collector will run is best left to JVM to decide. Well unless your program is about to start doing things that use a lot of memory and is speed critical so you may suggest JVM to run GC before going in as you may likely get the garbaged collected and extra memory to go on. Other wise, I personally see no reason to run System.gc().

    Hope this helps.

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

Sidebar

Related Questions

I know that Java enforce the programmer to list all exceptions that will be
I'm learning Java, and I know one of the big complaints about newbie programmers
I know this question is a bit silly. I am a Java Programmer that
I would like to know if Java supports casting and melting of data somehow.
As a (pedantic) beginner Java programmer I would like to know, is it a
As most Java programmers know, updates to Swing GUIs should only be done on
Lately I have come to realize that I should know some of Java for
When studying Java I learned that Strings were not safe for storing passwords ,
I have looked and could not find a library that would deal with problem
I know that even a question Erlang or Java seems quite strange, because they

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.