delphi123 Posted January 5, 2008 Share Posted January 5, 2008 hi folks, I suspect my code may be leaking memory (according to my host) - can anyone give me pointers on how you test whether it is leaking and how you can track down/isolate the cause? Quote Link to comment https://forums.phpfreaks.com/topic/84618-memory-leak-tracking/ Share on other sites More sharing options...
gerkintrigg Posted January 5, 2008 Share Posted January 5, 2008 and what exactly is your host referring to? If they mean you're using too much memory, try to consolidate your code. Make it more efficient. There's no real way of knowing what the problem is without a bit more info. Sorry. However a hint might be to start looking at SQL queries... Are you grabbing a million files or so, then using mysql_num_rows() or are you counting in the SQL Query using SELECT COUNT(*) as records? The first is bloated and takes a LOT more effort than the second. This might be what they're on about... Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/84618-memory-leak-tracking/#findComment-431150 Share on other sites More sharing options...
delphi123 Posted January 5, 2008 Author Share Posted January 5, 2008 thanks for the reply - they were saying that there was a while statement that caused it: 'The reason your while loop does not work is because you do not define the $column_counter variable before using it, nor do you increase it at all in the loop. So, the loop just continues to run until it eventually uses all the memory on the server.' I didn't realise you needed to increment while statements?! most tutorials seem to just say things like: while ($table = mysql_fetch_array($result)){ //do code } am I wrong? Also how can I check how much memory is being used? I'm running the code on localhost and I was wondering if there's any software that'll tell you what load the server is under etc? Quote Link to comment https://forums.phpfreaks.com/topic/84618-memory-leak-tracking/#findComment-431168 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.