java.exe process holding on to port 9001 after stop

Greetings -

I'm running a Screen Scraper service on a Windows machine and occasionally, I stop the service programmatically. I recently upgraded to SS 3.0.17a and now when I stop the service, a java.exe process is left over, and doesn't release port 9001, which makes restarting the service impossible - the left-over process even resists TerminateProcess due to the windows security bounaries, which is what is making me post.

Is this a known issue, and if so is there a workaround?

thanks,
-r

java.exe process holding on to port 9001 after stop

Hi,

Sounds like your best bet would be to find a way to reduce the amount of information you're saving in session variables. Bear in mind that this would be a problem in any programming environment--the more information you try to stuff in physical RAM, the quicker your app will run out of memory.

A couple of suggestions that might help
- Take a look at how we handle writing data out in our third (http//www.screen-scraper.com/support/tutorials/tutorial3/tutorial_overview.php) and fifth (http//www.screen-scraper.com/support/tutorials/tutorial5/tutorial_overview.php) tutorials. The idea here is to write out the data as quickly as possible once it's been extracted.
- If for some reason the above isn't viable, you might also look into caching data sets. See this page for a bit more on that http//www.screen-scraper.com/support/docs/using_extractor_patterns.php.

Todd

java.exe process holding on to port 9001 after stop

I get this too:

The error message was: The application script threw an exception: java.lang.OutOfMemoryError: Java heap space BSF info: null at line: 0 column: columnNo

I've followed the FAQ's on optimizing and increasing memory (to 1000 MB), and I've done everything except reduce the amount of information being saved in session variables, and clicking off "tidy html" which really would be problematic. I'm running screen scraper as a server, and starting it from the command line, and still it craps out after about 700 records (same as running it in the gui console, incidentally). Very frustrating! It seems there really ought to be a a way to clear this while the process is running.

java.exe process holding on to port 9001 after stop

Hi,

In that case, here are a couple of FAQ's that may help

http//www.screen-scraper.com/support/faq/faq.php#Optimizing
http//www.screen-scraper.com/support/faq/faq.php#VirtualMemoryIncrease

Feel free to post a reply back if neither of those help.

Todd

java.exe process holding on to port 9001 after stop

Ok, it looks like an unhandled exception in some subsystem triggers a process shutdown, which orphans the java.exe process hosting the database.

I finally observed a crash and realized that abnormal termination is what orphans the db process in this situation (not sure if this applies to using the Win32 SCM API, but it could be similar). Searching through the log files (all 537,000!) I found the following message. It appears that there could be a memory leak somewhere. The process itself, while running into the 600MB range, is on a box which can handle that kind of memory usage. Seeing the bit about the inability to create a native thread, it could be stack exhaustion, but I'd guess that would be a StackOverflowException or similar - but I have no clue how java handles native Win32 threads.

Processing script: "General--get current URL"
Search Results: An error occurred while processing the script: General--next page
Search Results: The error message was: The application script threw an exception: java.lang.OutOfMemoryError: unable to create new native thread BSF info: null at line: 0 column: columnNo

java.exe process holding on to port 9001 after stop

That'd be great if you could help reproduce the problem. I believe there's a way to have the wrapper.exe control both processes. I added that possibility to the bug I logged so that we can look into it.

Todd

java.exe process holding on to port 9001 after stop

Actually - I just noticed this behavior with the batch files as well on v3.18a. I'll try to repro it to get a better case for you, but I'm really crunched for time, so it may be a while.

In the mean time, have you considered using the Win32 Job API to batch these processes together, so that their lifetime is controlled as one unit?

java.exe process holding on to port 9001 after stop

Well, it's good to hear that that worked. We'll look into why it doesn't seem to work with the previous method you used.

Todd

java.exe process holding on to port 9001 after stop

Ok, I looked at the bat files and they appear to work, since somehow the "Wrapper.exe" process knows about shutting the DB java.exe process first. While this is really not optimal over using the built-in Windows APIs to do it, I'll accept that things have to be done this way. Ultimately it is not a Windows permissions issue, since the logon session I use to stop the services is the same - the same token with all the same privileges and rights for each method.

Thanks for pointing me to the Wrapper.exe program.

java.exe process holding on to port 9001 after stop

Hi,

When screen-scraper launches it spawns two processes--one for the server and one for the screen-scraper database. The database is run in a separate process in order to allow you to run the workbench simultaneous to running the server.

My best guess as to what's happening is that it has something to do with Windows permissions. If you start and stop the server using the corresponding shortcuts under the "Start" menu do you get the same effect?

Todd

java.exe process holding on to port 9001 after stop

Hi Todd -

Here are the details:

1) I'm using XPSP2.
2) I'm stopping the service using the Win32 Service Control Manager API.
3) I'm running the process that stops the service under an account that has admin privileges on the machine.

On further investigation, the SS service is running under a different logon session, and so the process I am using to monitor and control the SS service doesn't have ownership of the SS processes. This results in the Access Denied error when I try to kill it, even thought I have admin privs. Once I take ownership of the process, or enable the SeDebugPrivilegeName privilege on the process token, I can kill it.

However, this is all a bit heavy handed - the real problem is that when the service is shut down, a java.exe process is left over. Any idea why this happens?

java.exe process holding on to port 9001 after stop

Hi,

Thanks much for helping us test the latest alpha version of screen-scraper. I tried to reproduce the problem on a Windows XP machine, but was unable to. Could you provide a few more details that might help troubleshoot? The following would help

- What operating system are you running?
- What do you mean by stopping the service "programmatically"? Are you using one of the .bat files? Are you stopping via the system tray icon?
- I'm not sure I understand the trouble killing the process. Are you trying to stop it with a user account that has administrative privileges on the box?

Thanks much,

Todd Wilson

java.exe process holding on to port 9001 after stop

I see this a fair bit on a reallly old windows 2000 (rc1 patched) box with not enough memory and a slow processor (read: Not likely ss's fault since it's such a crappy box and os install) -- I use the SysInternals Process Exporer, which lets you kill things with much more power than the standard task manager. Kill's 'em dead every time.