Back to vBulletin 3 Articles

[How to] Cut down on memory usage
by Brad 07 Jan 2006

This is in the manual but I've yet to see it mentioned here.

The plugin system works by storing all plugin code for all scripts in memory, so you can quickly find your plugins using large amounts of memory if they contain a lot of code.

A simple way to avoid this problem is to use the plugin code simply to call an external script, which contains all the complex code. In this way the code is only loaded when it is actually required.

For example, a plugin could contain this:
PHP Code:
$tmp_uid =& $vbulletin->userinfo['userid'];

$db->query_write("
  INSERT INTO " 
TABLE_PREFIX "profilelog
  (userid, dateline)
  VALUES
  (
$tmp_uid, " TIMENOW ")
"
); 
or alternatively, that code could be placed into a file called (for example) plugins/my_script.php, and the plugin itself would contain this:
PHP Code:
include('./plugins/my_script.php'); 
Naturally, the second option will use up far less memory than the first, and this saving will become more and more beneficial as the amount of code to be run increases.
You should also take a look at this project: Plugin Accelerator

vblts.ru supports vBulletin®, 2022-2024