NetTalk Central

Author Topic: Garbage collection  (Read 5860 times)

oeb

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • Email
Garbage collection
« on: October 30, 2008, 05:17:00 AM »
Bruce (or anyone else with knowledge), would you please give some insight into how garbage collection in NetTalk works - and is there a way to manually trigger it/ make it happen sooner?

We have an atypical web application that provides status information from our software system. There will probably be just a couple of users viewing the page at the time, but the page is constantly updated through timers. The page might stay active for days and weeks at the time. It seems like memory usage grows very high (100 MB+) before any garbage collection happens. Memory use grows slowly all the time. With no web browsers active, there is no additional memory use, but it doesn't drop. I tried with a test application and it triggered at 170 MB (dropped to 24 MB), but it might not be really compareable This is private bytes as reported by Sysinternal's Process Explorer, that should be very accurate. Is memory use really supposed to run this high before any garbage collection happens?
--------------------
Ole

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11301
    • View Profile
Re: Garbage collection
« Reply #1 on: October 30, 2008, 11:09:24 PM »
Hi Ole,

Before we get into the specifics of the garbage collection, it's worth noting that _how_ you measure memory usage can be important.
(You've specifically mentioned this, but I mention it here for other readers of this thread.)

Windows is clever and at times won't report memory as being "free'd" unless it needs it for something else. So even if a program "frees" memory, windows cunningly leaves it allocated to the program on the grounds that "he may need it again". It's only if another app _needs_ the memory that it gets (visually) released.

So, especially using task manager, you have to be careful exactly "what" memory you are looking at.

Now onto the internals -
As you know there is a SessionQueue. When an "old" session is detected it is removed. A session gets "old" when it hasn't been "touched" for a period of time. The length of the period is set on the Web Server procedure extension (advanced tab.)  The default is 10 or 15 minutes, but often developers (including myself) extend this to 24 hours, or even 72 hours - depending on the nature of your site.

It sounds to me like
a) your session timeout time may be quite high and

b) perhaps the session value is _not_ being sent on your timer url. A worst-case scenario would be that you have a timer on a page, but each instance of the timer starts a new session. I don't think this would happen with the "built in" timer functions, but if you were calling a timer manually - or calling the server from a "non browser" then you would want to ensure that you were always passing the session id correctly.

Cheers
Bruce



oeb

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • Email
Re: Garbage collection
« Reply #2 on: October 31, 2008, 01:32:17 AM »
Thanks for your reply, but I think this must be something else. I've checked that the session ID is indeed passed with the URL for each timer event. Since the web browser stays open for hours the session will never really time out I suppose, so that is probably not relevant. I can send you a test application that demonstrates this, or do you have any more ideas first?
--------------------
Ole

oeb

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • Email
Re: Garbage collection
« Reply #3 on: November 06, 2008, 12:32:58 AM »
It turns out this effect was very hard to re-create in a test program. However, I've seen one thing: If I push and hold the F5-key (refresh) in a browser for a while I can create a massive memory increase in the web server. This drops after a short period of time after I release the key, but memory use never seems to drop quite as low as it was, it's always a few MB higher?
--------------------
Ole