Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

does memory usage always increase



12:09 am on Feb 17, 2012 (gmt 0)

5+ Year Member

function a iterates through itself, and can call function b.

memory usage slowly creeps up.

is it possible to have flat memory usage? it is my understanding that when a function ends, all the memory is freed up, but that does not seem to be the case here. there are no globals, no appending items to an array, b doesn't call a.


12:43 am on Feb 17, 2012 (gmt 0)

WebmasterWorld Administrator incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

We're talking function and not class?

Did you invoke any classes within the function?

FWIW, not all memory releases really release memory in ways that are immediately visible via stats of all memory used, etc. depending on the OS, Windows, Mac, Linux?


10:08 am on Feb 17, 2012 (gmt 0)

5+ Year Member

they are functions, and have not invoked any classes.

its running on linux.

im very new to the idea of keeping an eye on memory when coding, and I find it fascinating. ive set a lot of variables to NULL and have seen a big drop in the rate at which memory goes up.

memory_get_usage says it now increases at 100~ kilobytes with each iteration.

should I keep looking or is that a typical increase?


4:57 pm on Feb 17, 2012 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

100K per pass seems like a lot! :-) To put it in context, create 100 K image and look at it's size - depending on the compression method, this could easily be larger than any reasonable web browser viewport. Speaking of web pages, the "recommended" web page size is not to exceed 40K (but today, you're lucky to find one under 100K.)

Is there any way to flush any variables within this function? What is it doing that's using up 100K with each pass? Is it using global variables, or are all variables scoped to the function?

Featured Threads

Hot Threads This Week

Hot Threads This Month