Welcome Guest, Not a member yet? Register   Sign In
Memory usage question...
#1

[eluser]theQco[/eluser]
Hey everyone,

I have a fairly simple page that I am loading about 40 objects from a database - name and id.

My profiler output is as follows:

Memory Usage: 3,303,728 bytes ( 3,344,704 peak bytes )

Benchmarks:
Loading Time Base Classes 0.0117
Controller Execution Time 0.0518
Total Execution Time 0.0636

Get Data: No GET data exists

Post Data: No POST data exists

Database: 1 query - 0.0011


The time is fine. I am just unsure whether 3MB is normal memory usage. I realized you don't have my query or code but the question I have is: does it seem normal that one query selecting 2 columns (name (varchar 100) and id (int 11) and returning about 40 rows would take up 3MB of data. I'm not sure what this 3MB is consisted of. Is it the whole page, ie: images, css, plus the memory needed to execute?

Any thoughts would be appreciated. Thanks!
#2

[eluser]Dam1an[/eluser]
A clean install is around 700K (if I remember correctly)
Once you autoload the session and database (which I always do) you're up to ~1.6Mb

If I'm not mistaken, the loading time of images etc, isn;t included, as thats all client side stuff, the time is just how long it takes to render the HTML page

And I would be a bit concered about 3+Mb for a simple query, as I have complex pages (with additional libraries and helpers), 60+ queries, and I've never gone over 2Mb (yet)
#3

[eluser]TheFuzzy0ne[/eluser]
Could it be that you have a higher memory limit than normal, so PHP is taking advantage of that?
#4

[eluser]slowgary[/eluser]
Try commenting out sections of your code, one section at a time. See if you can isolate the hog.
#5

[eluser]Dam1an[/eluser]
[quote author="slowgary" date="1240853897"]Try commenting out sections of your code, one section at a time. See if you can isolate the hog.[/quote]

The problem with that, is most code is dependant on previous code, so if you comment out part of the model, you get errors when it tries to access the results of the model call

Instead, you could either stub methods to return a value which will work, or create small test cases, such as just the query on its own, the qiery within the model etc
#6

[eluser]slowgary[/eluser]
Comment out the processing code first, then echo a serialized copy of your db results, and just return an unserialized copy from your db functions.
#7

[eluser]slowgary[/eluser]
You wouldn't happen to be running it on Windows, would you? If so, you're getting GREAT performance. I would expect it to be using something more like 220MB on a Windows server.
#8

[eluser]theQco[/eluser]
Ha. No Windows Server - running OS X 10.5.

I don't want to waste too much time trying to prematurely optimize the code at this point. I just wanted to get a sense of whether my memory usage was normal or not. I'll play around with removing some of my autoloaded classes and helpers and see what I can do once the rest of the site is up and running.

Thanks for the comments so far. I'll keep you posted as I debug.
#9

[eluser]deanf7[/eluser]
Any suggestions general suggestions for reducing memory load on a page running 0 queries, but still using 2,732,616 bytes of memory. I develop on Windows and page loading is fine. The memory usage is very similar when I move it over to our dedicated Linux server, where the app. runs brutally slowly.

Thanks
#10

[eluser]slowgary[/eluser]
As far as I can tell, CI uses about 1MB on it's own. So you're at about 1.7MB. I assume you're loading some libraries, or you just have a LOT of variables. The only suggestion I can make is... make sure you're only loading libraries where needed, so don't autoload them in your config, and don't load them in your class constructors, only load them in the actual function that needs them, this will help avoid loading libraries that you don't even need.




Theme © iAndrew 2016 - Forum software by © MyBB