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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ajlisowski
Forum Newbie
Posts: 22
Joined: Wed Dec 16, 2009 8:22 pm

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

Post 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.
Last edited by ajlisowski on Mon Jan 18, 2010 1:14 pm, edited 1 time in total.
ajlisowski
Forum Newbie
Posts: 22
Joined: Wed Dec 16, 2009 8:22 pm

Re: Website freezes until apache restart...

Post 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.
ajlisowski
Forum Newbie
Posts: 22
Joined: Wed Dec 16, 2009 8:22 pm

Re: Website freezes until apache restart...

Post 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.
Post Reply