Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Optimize Memory Usage?

storing data in session vs. running same methods on every page

6:23 pm on Jun 27, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 12, 2004
votes: 0

So my main question is this.

I want to determine wether I should store information in session or run the method for every page call.

Storing to session costs about .5 MB. How can I determine the use of resources for running the methods that create the data?

I need the data for every page. I figure its less work recalculating the data all the time, but has a memory cost.

The memory cost should be the same when the page is being requested regardless of Session or running the data on the fly, but CPU usage will go up during the calculations.

However, I believe php garbage collection will release the memory usage as soon as page request is complete.

Any ideas on how to optimize this?

12:09 pm on June 28, 2009 (gmt 0)

Full Member

10+ Year Member

joined:Dec 8, 2005
posts: 231
votes: 0

well a useful guideline is to store data that rarely changes as session data (e.g. username, dob).

sorry i cant offer anything more specific.

12:38 pm on June 29, 2009 (gmt 0)

Junior Member

10+ Year Member

joined:Aug 12, 2004
posts: 107
votes: 0

Thanks...what Im going to do, is calc the array size, and set some limits and play with that. Ill also set a session on/off global for using session for my arrays.

Play with those limits and try to figure out the best combination.