Optimizing Plugin Memory Usage 
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:
$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:
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.
Albert Davidson Chou 25th Mar 2006, 08:30pm
To avoid others having to look up the PHP include() function's documentation as I did, note that when you take plugin code and put it into an external file as in the example here, include() requires that you surround the code in that file with the PHP tags, e.g.,

<?php
// your plugin code goes here
?>