We are about to switch to a new forum software. Until then we have removed the registration on this forum.
I'm using a Raspberry Pi 2 with the raspbian jessie image. Processing and the G4P lib and gui builder are working very well but when I close a window by clicking the 'x' the task manager still shows a java thread and a thread with the name of the sketch still running. The java thread is also still consuming some CPU time. So, by using the exit() function what code should I be using to do a complete 'clean up' ??
Answers
Couple of questions first.
1) Are you creating multiple windows using GWindow
2) The window you are closing the main sketch window (which stops the application) of is it a GWindow object?
No multiple windows just the main sketch window.
Have you tried it without any G4P controls?
Yes, the problem occurs with just a plain sketch without G4P.
That means it is not caused by G4P.
Back in a few minutes :)
As far as I remember I had a similar problem running Processing sketches in Eclipse on a Windows machine. It was a long time ago but I remember having the Task Manager open and closing the sketch-application manually.
I don't know what is causing the problem but you might like to try this sketch out. It will show you the threads that are running at different times in your program.
This sketch has 2 tabs, the second one is a Java tab NOT a pde tab.
Try running the sketch and then closing the window, with Task Manager open.
Main Sketch Tab
Java tab named
ThreadInfo.java
Look for this line in the output
THREAD: DestroyJavaVM: Priority: 5 [Alive]
This is the output I got when I ran the program and clicked on the red X
Ok, I created the sketch as per your advice and when I close the processing window the task manager still shows the name of the sketch thread and a java thread. The java thread is still using CPU time but the sketch thread is not.
Don't forget that the Processing IDE will also appear in Task Manager
I have changed the name and category for this discussion because it is not about G4P anymore and you might get more comments that way.
Thank you for changing things around. When I run the sketch from within the IDE then close it with the IDE's stop button garbage collection works as it should and the task manager shows a complete clean up.
When the sketch is run within the IDE and then closed the task manager still shows two threads one for the sketch and one for the IDE. But when I close the IDE a complete clean up occurs. So this problem is just occuring on the exported 'stand alone' executables. I'm hoping that just a few lines of code within an exit() function can solve the problem.
Success!....Problem solved by using the code below. This did a complete clean up for an exported executable:
void exit() { noLoop(); this.dispose(); System.exit(0); }
Can someone please change the status of this thread to 'answered'