I have a question about plugins and if there several plugins that load the same API codes . are they uploaded once or multiple times for each plugin reference in memory?
Resources and Memory Allocation in Plugins
-
- English
- angriff
- Thread is marked as Resolved.
-
-
I have a question about plugins and if there several plugins that load the same API codes . are they uploaded once or multiple times for each plugin reference in memory?
What you mean by "load the same API code"? the import statement? import's are not "loaded" and do not occupy memory at run time, they are only used at compile time to resolve external identifiers.
-
Ok well the question came up with what Minos said that we would not load all the libraries in a plugin when you are putting together some code. I was make a call to a connection and kept getting an error until i found the single java.sql class package that made it go away. It was not intuitive in my opinion. I also create a lot of little plugins for my server that use common libraries. I find it easier to upgrade them that way but I wanted to make sure I was not slowing down computers doing that. Also I see that area protection and some third party plug-ins load tons of lines in the logs that appears to slow down boot into the game so I wanted to discuss optimization.
from another thread..............Minos reply excerpted.
To be able to use all the classes of a package you need to import it as java.sql.* so that the import includes all the classes of the package and not just one.
having said that though it is not good practice to import huge packages if you are only going to use 3-4 classes thereof
-
Also I see that area protection and some third party plug-ins load tons of lines in the logs that appears to slow down boot into the game
I do not understand what you mean here: which "lines" the plug-ins "load" and how could this "slow down boot into the game"?
(Incidentally: the current Area Protection script is not Java but LUA and, as such, none of this discussion applies to it.)
Minos reply excerpted.
To be able to use all the classes of a package you need to import it as java.sql.* so that the import includes all the classes of the package and not just one.
having said that though it is not good practice to import huge packages if you are only going to use 3-4 classes thereof
Yes, this is not considered good practice or good coding style. However, import's have no impact on memory.
I also create a lot of little plugins for my server that use common libraries.
"Lots of little plug-ins": this may have an impact on load time (and marginally on memory occupation). If a plug-in is split into two covering the same functionality, loading will require more file accesses and so on and will be (slightly) slower. Each plug-in also has some standard boilerplate contents and some "architectural sugar" which needs to be repeated for each plug-in. So, excessive fragmentation may be a (small) problem, if does not correspond to a functional separation.
"Common libraries": what do you mean by this? Which libraries beyond the Java own libraries and the RW API jar (both of which are loaded always but only once for the whole RW process)?
If you add third party libraries (which probably you cannot install in the Java VM of a commercial game server host), this may affect loading time and memory occupation (it shouldn't affect performance: if the methods you use from them are really needed, that CPU load is going to happen anyway...).
-
Well you managed to lose me in all that.. so I will just go with no it does not affect it unless you fragment similar operations with multiple plugins.
If I have 15 listeners listening for a similar event then maybe yes.. I guess
Participate now!
Don’t have an account yet? Create a new account now and be part of our community!