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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:00:03+00:00 2026-06-17T23:00:03+00:00

I have an application with AWT GUI, and I use JTextArea for logging output.

  • 0

I have an application with AWT GUI, and I use JTextArea for logging output. If I erase the text with setText(null) or removeAll() or setText("") and then run garbage collector System.gc(), I notice that the whole text still in memory. How can I really delete the text?

I’m not very familiar with profiler, here is what I see in memory dump after setText(null):

profiler snapshot

  • 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-17T23:00:05+00:00Added an answer on June 17, 2026 at 11:00 pm

    Please have a read on: How Garbage Collection works in Java.

    As per the docs System.gc():

    Calling the gc method suggests that the Java Virtual Machine expend effort toward recycling unused objects in order to make the memory they currently occupy available for quick reuse. When control returns from the method call, the Java Virtual Machine has made a best effort to reclaim space from all discarded objects

    NB – suggests. This means that the garbage collector is only suggested to do a clean up and not forced also it may entirely ignore your request, thus we cannot know when the garbage will be collected only that it will be in time.

    NB – disgarded objects: this refers to all objects that are not static/final or in use/referenced by any other instances/classes/fields/variables etc.

    Here is also an interesting question I found on the topic:

    • Why is it a bad practice to call System.gc?

    with the top answer going along the lines of:

    The reason everyone always says to avoid System.gc() is that it is a
    pretty good indicator of fundamentally broken code. Any code that
    depends on it for correctness is certainly broken; any that rely on it
    for performance are most likely broken

    and further there has even been a bug submitted for the bad phrasing of the documentation:

    • https://bugs.java.com/bugdatabase/view_bug?bug_id=6668279

    .

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

Sidebar

Related Questions

I have an AWT applet application that needs to be ported over to GWT.
I have application which needs to use a dll (also written by me) which
I have a windows application which has a complex GUI that I would like
This is driving me nuts. I have a working text based application. It has
When I run my swing GUI applications under Java 6, they automatically use my
I have been coding an application which renders tiles and GUI and all that.
How can I restart a Java AWT application? I have a button to which
I have built this application and I tried to run it but I could
I have a Class MyClass, that when it runs it initialize a GUI awt
For a GUI application I am creating in Java, I have the following: A

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.