Page 1 of 1

Website freezes until apache restart...[SOLUTION WITHIN]

Posted: Mon Jan 18, 2010 12:31 pm
by ajlisowski
Hi, I am experiencing an issue with a system I am building in PHP. There is a lot of data being called to a page and the load time for the server is far too large. However, I will have to deal with that myself. My issue is that, in the mean time, while the site is loading if I refresh my browser, the page gets stuck in "waiting for localhost" until I restart apache.

I have no idea what could be causing this. Even on smaller pages in my system that barely take any time to load, if I manage to refresh during the "waiting for localhost" moment, the page just gets stuck there. Any idea what could be causing this? Ive tried building a very small php page that just echos something out and seeing if I could get it to do the same, but I can not.

Is it perhaps memory management? How does PHP handle variables? Is it up completely to me to clear out variables once I am done using them? Or does php have garbage collection? I always assumed it did since ive never really had to worry about it before.

Re: Website freezes until apache restart...

Posted: Mon Jan 18, 2010 12:41 pm
by ajlisowski
I narrowed it down a bit and it appears to be any php page which calls session_start() will leave the page stuck loading, waiting for local host.

Re: Website freezes until apache restart...

Posted: Mon Jan 18, 2010 1:14 pm
by ajlisowski
I beleive I have solved the issue. It appears as though what was happening is the second or third request to the page on refresh was trying to access the session, but for some reason, the session was still locked out from the previous request since it did not finish loading the page and thus, unlocking it. To solve the issue I used session_write_close() immediately after starting the session. This will lock out writing but leave reading open. Thus, the session is no longer locked out and the page doesnt hang trying to grab it.