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

  • Home
  • SEARCH
  • 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 8193171
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:23:54+00:00 2026-06-07T04:23:54+00:00

I having some memory issue with Java and Swing. I have a JTextArea (same

  • 0

I having some memory issue with Java and Swing. I have a JTextArea (same issue with JTextPane) that I use to redirect stdout from an C++ executable. And because I’m outputting a lot of stdout, JTextPane is consuming a lot of space. In any case, I boiled it down to the following code, all in Java.

private javax.swing.JTextArea jtextareastdout;
....

for (int i = 0; i < 200000; i++) {
    String randomstr = UUID.randomUUID().toString();

    jtextareastdout.setText(randomstr);  //<tag_memory>
    if (i % 100 == 0)
        System.gc(); //<tag_no_help>
}

The above code consumes 100MB. With tag_memory line commented out, a lot less (30MB with all my other code & UI). How can I reduce Java’s memory usage? Currently using Java 7 update 4.

Thanks in advance.

  • 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-07T04:23:55+00:00Added an answer on June 7, 2026 at 4:23 am

    I just don’t understand where all the memory is going.

    PlainDocument tells the story: either one or two 16-bit code units per code point, a map of line starts and all the impedimenta needed to make it editable. For read-only viewing, I’d use redirection: yourprogram 2>&1 > view. In Java, you could read from stdin into a List<String>, with one String per line, and view it with a JTable. The default renderer is quite efficient. There’s a related example here.

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

Sidebar

Related Questions

I've been having this memory leak issue for days and I think I have
Hey I seem to be having some kind of memory leak issue with my
am having problem in Saving some data in my Java code. I have like
My Audio Unit analysis project is having some memory issues, whereby each time an
I'm running into some issues with having a lot of UIImages in memory, so
I'm currently battling through some memory leaks and having some serious trouble working out
guys am having some troubles with running out of memory when displaying an animation
I'm having some problems implementing an algorithm to read a foreign process' memory. Here
Having some trouble with R's garbage collection, when passing objects to C++. We have
Let us say we have some code that looks like below: @interface SomeClass :

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.