[drupal-devel] Memory profiling for modules
Mike Gifford
mike at openconcept.ca
Wed Aug 10 15:00:07 UTC 2005
Hi folks,
I was installing Civicspace a little while ago and was surprised that
the installer recommended a non-standard memory_limit (8Mb is likely
what most hosts provide and expect it is what most distros send php
out with).
I decided to set it up with 8M locally anyways, and most stuff seems
to run except for a list of admin
modules:
?q=en/admin/modules
Neil Drumm informed me that the modules page "needs to get the
metadata for all the modules
which is stored in each module's php code. So that page loads /every/
module. That takes a lot of memory."
Might be good to build some type of pagination in here for users who
don't have a lot of flexibility with their web hosts, root access or
confidence to muck about in the php.ini file.
Anyways, I created this small patch to the drupal CVS which would
allow developers to pretty quickly see what modules are sucking up
the most memory:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: module.inc.patch
Type: application/octet-stream
Size: 1817 bytes
Desc: not available
Url : http://drupal3.drupal.org/pipermail/development/attachments/20050810/816e99cb/module.inc.obj
-------------- next part --------------
It produces results like this (although this is based on CivicSpace
0.8.1.2 code):
Memory Usage before modules are loaded: 1,148 Kb
Memory Usage (1) block: 1,267 Kb -- Change 119 Kb +
Memory Usage (2) blog: 1,327 Kb -- Change 60 Kb
Memory Usage (3) book: 1,499 Kb -- Change 173 Kb +
Memory Usage (4) comment: 1,903 Kb -- Change 404 Kb ++++
Memory Usage (5) contact_manager: 2,255 Kb -- Change 352 Kb +++
Memory Usage (6) contact_manager_forms: 2,319 Kb -- Change 64 Kb
Memory Usage (7) drupal: 2,371 Kb -- Change 52 Kb
Memory Usage (8) filter: 2,592 Kb -- Change 222 Kb ++
Memory Usage (9) forms: 2,659 Kb -- Change 66 Kb
Memory Usage (10) forum: 2,873 Kb -- Change 214 Kb ++
Memory Usage (11) help: 2,889 Kb -- Change 16 Kb
Memory Usage (12) massmailer: 3,211 Kb -- Change 322 Kb +++
Memory Usage (13) menu: 3,325 Kb -- Change 114 Kb +
Memory Usage (14) node: 3,719 Kb -- Change 394 Kb +++
Memory Usage (15) node_import: 3,799 Kb -- Change 80 Kb
Memory Usage (16) notify: 3,816 Kb -- Change 17 Kb
Memory Usage (17) page: 3,829 Kb -- Change 12 Kb
Memory Usage (18) path: 3,885 Kb -- Change 56 Kb
Memory Usage (19) phplist: 3,996 Kb -- Change 111 Kb +
Memory Usage (20) search: 4,132 Kb -- Change 137 Kb +
Memory Usage (21) statistics: 4,241 Kb -- Change 109 Kb +
Memory Usage (22) story: 4,253 Kb -- Change 11 Kb
Memory Usage (23) system: 4,445 Kb -- Change 192 Kb +
Memory Usage (24) taxonomy: 4,683 Kb -- Change 238 Kb ++
Memory Usage (25) textile: 5,308 Kb -- Change 625 Kb ++++++
Memory Usage (26) urlfilter: 5,316 Kb -- Change 9 Kb
Memory Usage (27) user: 5,802 Kb -- Change 486 Kb ++++
Memory Usage (28) watchdog: 5,840 Kb -- Change 38 Kb
Memory Usage after all modules are loaded: 5,840 Kb
I think that this could be useful for other folks who are looking at
general profiling issues too. You need to enable the code by turning
$profileMemory = true;
There's likely a more graceful way to do this, but I'm still rather
new to Drupal. This code also only works if you have
memory_get_usage in your php install.
Mike
--
Mike Gifford, OpenConcept Consulting
Free Software for Social Change -> http://www.openconcept.ca
Latest launch Canadian Labour Congress / Congr?s du travail du Canada
http://canadianlabour.ca / http://congresdutravail.ca
More information about the drupal-devel
mailing list