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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T18:46:18+00:00 2026-06-04T18:46:18+00:00

I am creating a java program, in which some data is added to an

  • 0

I am creating a java program, in which some data is added to an arraylist.

Some of the processing is within a loop, and I am adding a new node to the list within the loop, performing operations using that node, and then deleting that node using arraylist.remove() just before end of an iteration of the loop. I am also running System.gc(); just before end of a loop iteration.

However when I took a memory dump, I found that the arraylist still held all values that I had used in different loop iterations… How do I erase all of those values from memory? And I want to do this just before the end of an iteration of loop, so that the arraylist never grows in size?

  • 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-04T18:46:22+00:00Added an answer on June 4, 2026 at 6:46 pm

    Java have garbage collector for a reason, and that reason is to programmer don’t have to think about removing object from memory. Only thing you can do (I don’t recommend it) is to force start garbage collector by System.gc() method. But remember to do it twice because 1st time it will only prepare object to be removed by invoking it finalize() method.

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

Sidebar

Related Questions

I'm creating a windows service program which invokes a java program. Here is part
I am creating a simple reporting program using java and iReport (from jasper), which
I'm using the operating systems dictionary file to scan. I'm creating a java program
When creating applications (Java, run on a normal computer). How important is program size
im creating a program that will compile java files, at the moment i have
I'm creating a Java application where the user can search through a list of
I am currently creating a java application in which I have a 2d array
I am creating an application which uses the Java Plugin Framework to load plug-ins
I am creating a GUI using Java. This GUI launches a program from the
I wrote this simple Java program which connects to internic server and returns the

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.