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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:40:35+00:00 2026-06-07T22:40:35+00:00

This is part of larger graphing program (JavaPlot specifically). In a nut shell, I

  • 0

This is part of larger graphing program (JavaPlot specifically). In a nut shell, I would try to graph something; the graph would appear at

out.write(comms); 

but then close once it hit

out.close()

I know you need to close OutputStreamWriter, so instead of removing that line, I created a Scanner that waits until the user presses ‘Q’ and then the program continues as normal, closes the graph, the OutputStreamWriter, and the Scanner

        OutputStreamWriter out = new OutputStreamWriter(proc.getOutputStream());
        out.write(comms);
        out.flush();

//added from here
        //waiting until input is given
        Scanner timeKiller = new Scanner(System.in);
        String check = timeKiller.nextLine();
        if(check != "q"){
            check = timeKiller.nextLine();  //<---waiting here. 
        }
        timeKiller.close();
//to here

        out.close();

Is what I’m doing dangerous? If someone closes the graph by closing the window, this won’t kill the program, correct? This won’t cause a memory leak (right?) but if the process is still running and they run this program several times, it will eventually start to be an issue. How can I fix this? Just off the top of my head, maybe add a listener to the window that breaks the loop if the window is closed? Or am I mistaken and this is isn’t an issue at all?

  • 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-07T22:40:37+00:00Added an answer on June 7, 2026 at 10:40 pm

    If you have flushed the stream / writer after the most recent write, then you won’t lose any data if you exit the application without calling close on the stream first. And if you are exiting the application, the JVM terminates and storage leaks become irrelevant.

    On the other hand, if you don’t cause the application to exit when it arguably should exit, and the user spawns multiple instances as a result, you’ll have a problem with lots of JVMs filling up the user’s PC’s memory. If that happens, the hypothetical leaked stream is insignificant compared with dealing with the orphanned JVMs.

    But it is really unclear from your question what you are actually doing and/or proposing to do, so I can’t really comment on your specific situation.

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

Sidebar

Related Questions

(this is indirectly a part of a much larger homework assignment) I have something
I am getting this error as part of this larger puzzle here . var
I have a function that - as a larger part of a different program
It's a part of larger code base, which forces -Werror on gcc. This warning
This is part of a larger statement, but I'm wondering if CTE or another
This part of my code works fine: #include <stdio.h> int main(){ //char somestring[3] =
This part of my code is used to award a grade to a student
This part of an app that I am working on, I have the following
Considering this part of a Java class, private List<Object> components = new ArrayList<Object>(); private
I have this part of script from my GAE application which uses webapp2, which

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.