vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3 Articles (https://vborg.vbsupport.ru/forumdisplay.php?f=187)
-   -   [How to] Cut down on memory usage (https://vborg.vbsupport.ru/showthread.php?t=104657)

Brad 01-05-2006 10:00 PM

[How to] Cut down on memory usage
 
This is in the manual but I've yet to see it mentioned here.

Quote:

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: https://vborg.vbsupport.ru/showthread.php?t=107315

Paul M 01-06-2006 09:27 PM

Would this slow execution if lots of plugins were calling lots of files ?

The Geek 01-06-2006 09:38 PM

Quote:

Originally Posted by Paul M
Would this slow execution if lots of plugins were calling lots of files ?

A lot less then housing all the PHP for all files in memory at all time.

The bulk of my processing is done via external files.

Milad 02-03-2006 06:24 AM

Quote:

Originally Posted by Paul M
Would this slow execution if lots of plugins were calling lots of files ?

I agree

I think files modifications would be better for this purpose

Marco van Herwaarden 02-03-2006 07:28 AM

I have been thinking about creating an extension that will allow 'include-files' for plugins. They would be loaded as regular plugins (not file uploads), and can be loaded into memory whenever needed (for example: require_pluginlibrary_once('myfunctionlibraryplugi n'); ).

Like this you might get the best of both worlds:
- No file uploads
- Only loaded into memory when needed

PennylessZ28 02-03-2006 04:26 PM

I like that concept, I think I am going to play with this some more.

99SIVTEC 02-03-2006 04:30 PM

i'm ditching the plugin system on most of my larger sites. I'm just hardcoding the hacks. The plugin system is great in principal, but it eats up memory, increases queries, and slows down execution.

PennylessZ28 02-03-2006 04:36 PM

Quote:

Originally Posted by 99SIVTEC
i'm ditching the plugin system on most of my larger sites. I'm just hardcoding the hacks. The plugin system is great in principal, but it eats up memory, increases queries, and slows down execution.

Oh so true. If only there was a way to use this concept of the xml plugin to also upload a file like the above. So its not stored in memory.

Marco van Herwaarden 02-03-2006 06:37 PM

Quote:

Originally Posted by 99SIVTEC
i'm ditching the plugin system on most of my larger sites. I'm just hardcoding the hacks. The plugin system is great in principal, but it eats up memory, increases queries, and slows down execution.

If coded for saving memory(ie. 99% of executable code in include files), a plugin don't need to use much memory, nor does it need to use more queries or slow down significantly.

amykhar 02-03-2006 06:40 PM

Quote:

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

I feel better now. Somebody griped when I wrote my Amazon plugin this way :D


All times are GMT. The time now is 07:48 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01311 seconds
  • Memory Usage 1,736KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (2)bbcode_php_printable
  • (6)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete