Quote:
Originally Posted by CT_Spawn
32*32*4=4096 .....(1)
+
39*32*4=4992 ....(2)
(1) + (2) = 9088 Bytes
************************
24 * 60 = 1440 minutes
map time = 10 minutes
1440/10 ======> have 144 map in one day
so
9088 * 144 = 1308672 Bytes = 1.25 mb in one day
so
1.25 * 30 = 37.5 mb in 1 month
so
37.5*12=450 mb
This is just what we calculated on my plugin
So what if we count the other plugins?
Also, the system and the server software, we assume that they both carry 750 MB without taking into account additional other plugins, and I add only my 450 MB program to them.
That means the total is 1.2 GB
Imagine that the server only has 1 GB of RAM
It's strange to see a programmer bragging about memory loss like you
Didn't you study web programming and learn from it that you should do your best to reduce the volume, even if it is small?
|
Who are you mentioning in the end of your comment?
These calculations you did makes no sense man.
PHP Code:
new steamid[32],ip[39]
These variables were created locally inside the public function in your plugin, which means they are created in the moment the function is called.
Their memory is allocated in the moment they are created, and deallocated/deleted/freed as soon as the function execution ends.
All this is handled by your server computer at runtime.
Differently of this, global variables memory usage is kept during all the time your plugin is running and their memory usage does not change during gameplay.
PHP Code:
new global_variable_outside_codeblock;
In Small (Pawn) this integer-type variable will occupy 4 bytes in a 32-bit system and 8 bytes in a 64-bit system.
This memory will be released only when the server shuts down.
For example, this is what occurs supposing your function is called every time a player connects:
Using local variables (RAM friendly, CPU expensive)
PHP Code:
public On_Client_Connect(id) {
// Creates the variables and allocate their memory as soon as a player connects.
new steamid[32],ip[39]
if(something(steamid || ip)) {
make_something
}
} // Deletes the variables and frees their memory after all the steps are finished.
Using global variables (RAM expensive, CPU friendly)
PHP Code:
// Creates the variables and allocate their memory once when the plugin is initialized.
//This is outside the code blocks.
new steamid[32],ip[39]
public On_Client_Connect(id) {
if(something(steamid || ip)) {
make_something
}
}
This code will execute faster, although the memory used by the variables will not be freed.
__________________