reduce memory usage

Wesley Tanaka - January 21, 2006 - 10:29
Project:Event
Version:5.x-2.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

The event module is taking up almost a megabyte by itself on my site. Is it possible to reduce the footprint that gets loaded into memory, at least on pages that don't use the module?

#1

killes@www.drop.org - January 21, 2006 - 13:04

The problem is that you can't tell where the module is being used due to the blocks that are provided by it.

#2

Wesley Tanaka - January 21, 2006 - 14:11

The method I've been using in my own modules is to leave hook_menu, hook_block, hook_help, etc inline in the .module file, and copying all the other functions to a separate auxiliary file. All functions that need to be public remain defined in the .module file, but have a body like this:

function myfunc($arg1, &$arg2)
{
include_once dirname(__FILE__).'/mymodule.inc';
auxiliary_myfunc($arg1, $arg2);
}

If (for example) hook_block is big, and not called from every single page, I extract that body into its own separate file and include it using the method above.

#3

killes@www.drop.org - January 21, 2006 - 14:26

Well, I am not opposed to this. Send patches. :)

#4

Wesley Tanaka - January 21, 2006 - 14:46

Does that mean it will get committed? :)

#5

killes@www.drop.org - January 21, 2006 - 14:48

If it a) works and b) does not make the code too unreadable, why not?

#6

Wesley Tanaka - January 22, 2006 - 10:30

Previously event.module was using up 1622352 bytes on load. After this patch, it uses 243944 (initially) on load.

AttachmentSize
event-memory.zip 39.95 KB

#7

Wesley Tanaka - January 22, 2006 - 13:28
Status:active» needs review

#8

drewish - January 22, 2006 - 23:30

"If it a) works and b) does not make the code too unreadable, why not?"

If that's the criteria then I'll bring 40222 and #40720 to your attention.

#9

killes@www.drop.org - May 20, 2006 - 08:08
Status:needs review» needs work

Due to other patches being appled this wont apply anymore. Please don't attach zips.

#10

killes@www.drop.org - May 20, 2006 - 08:39
Status:needs work» fixed

I have changes event.module to not include event_timezones.inc on all page views. I guess that will fix most of this. I mark this fixed, but invite everybody to send more patches.

#11

Anonymous - June 3, 2006 - 08:45
Status:fixed» closed
 
 

Drupal is a registered trademark of Dries Buytaert.