Jump to content

Memory leak and hook flooding

Pending 1.0.38

ToliburtiX
ToliburtiX

Posted

Hello,

I saw this behaviour on my production server, but proved it with a fresh installation of rust-server and carbon framework. The map (3000) is new procedural generated. No players are on the server (except me as admin) and no items deployed at all.

But: As the carbon-console-command "plugins" shows, DeployableNature consumes 1000x more hook events than other plugins, and the memory is constantly growing. On my production server it was 3GB after 2 or 3 days, and it will lead to a out of memory crash, if you are not restarting the rust-server at a regular basis.

Greetings,
Toli

plugins.txt

ToliburtiX

Posted

Wow, see attached plugins.txt, after 3 hours of runtime, DeployableNature consumes 8 GB of "hook memory". Without a single Item deployed. 😞

 

plugins.txt

  • Curator
imthenewguy

Posted

You don't happen to have any data as to what hooks are causing the issue by chance?

The hooks I subscribe to (for the most part) should only be running when players are on the server.

OnActiveItemChanged - Can be disabled by setting the following config option to false: "Display a chat message when a player pulls out a hammer for the first time, reminding them that they can remove deployables"

CanNpcEat
OnItemRecycle
OnDispenserGather
OnDispenserBonus
OnCollectiblePickup
OnLootSpawn
OnPlayerDeath
OnPlayerAttack
OnMaxStackable
CanCombineDroppedItem
OnServerInitialized - Triggered when the plugin starts.
OnMeleeAttack

OnNpcTarget - Heavy - Can be disabled by setting "Prevent wild animals from targeting and killing deployed animals?" to false.

OnEntityKill
OnEntityTakeDamage
OnEntityDeath
OnEntityBuilt
CanBuild

OnPlayerInput - Very heavy - Can be disabled by setting "Allow players to use their middle mouse button to remove an item with a hammer (they can still use chat command regardless if they have perms)" to false.

OnServerSave

 

ToliburtiX

Posted

10 hours ago, imthenewguy said:

You don't happen to have any data as to what hooks are causing the issue by chance?

Well, looking deeper I think I found the problem. It's the plugin RoamingNPCs which constantly calls the hook "IsDeployableNature". I have only 8 NPCs configured to run around on the map and collecting resources, which seems to create this huge overload.

Is this a problem of DeployableNature or RoamingNPCs? Who will solve it?

  • Curator
imthenewguy

Posted (edited)

What method are they using to call the IsDeployableNature method?

Are they doing a HookMethod call from their plugin (DeployableNature.Call("IsDeployableNature", entity)?

or are they doing Interface.Oxide.CallHook("IsDeployableNature", entity)?

 

I can add some optimizations to filter out simpler queries such as entities that have no skin ids, but ultimately it would be up to the NPC plugin to reduce it's checks (IE caching entities that it has already checked etc).

 

Edited by imthenewguy
ToliburtiX

Posted

Well, as far I can see they define a method and use it in their code. I will only give this small general code example, because it's not open source. I asked them to have a look here in this support ticket an maybe contact you.

...
public bool IsDeployableNatureEntity(BaseEntity entity) => DeployableNature?.Call<bool>("IsDeployableNature", entity) ?? false;
...
...
private bool CheckResources(BaseEntity resource)
{
    if(resource == null) return false;
    if (instance.IsDeployableNatureEntity(resource)) return false;
    ...
}

 

2.2m

Downloads

Total number of downloads.

10.1k

Customers

Total customers served.

146.7k

Files Sold

Total number of files sold.

3.1m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.