*BUG* MemoryLeak + high CPU usage in editor

Hi,

I’m facing to a huge memory leak + bug using Event Blueprint Initialize Animation.
According to the documentation, Event Blueprint Initialize Animation must be called only once. Apparently, an object seems to be created when we pass the mouse in the content browser.

This is a simple AnimationInstance derivated blueprint that create a huge CPU + memory leak in the editor:

Then if you pass your mouse in the content browser, “Hello” will be displayed in the debug console, as following:

Log output:

LogBlueprintUserMessages: [TestAnim_C_1] Hello
LogBlueprintUserMessages: [TestAnim_C_2] Hello
LogBlueprintUserMessages: [TestAnim_C_3] Hello
LogBlueprintUserMessages: [TestAnim_C_4] Hello
LogBlueprintUserMessages: [TestAnim_C_5] Hello
LogBlueprintUserMessages: [TestAnim_C_6] Hello
LogBlueprintUserMessages: [TestAnim_C_7] Hello
LogBlueprintUserMessages: [TestAnim_C_8] Hello
LogBlueprintUserMessages: [TestAnim_C_9] Hello
LogBlueprintUserMessages: [TestAnim_C_10] Hello
LogBlueprintUserMessages: [TestAnim_C_11] Hello
LogBlueprintUserMessages: [TestAnim_C_12] Hello
LogBlueprintUserMessages: [TestAnim_C_13] Hello
LogBlueprintUserMessages: [TestAnim_C_14] Hello
LogBlueprintUserMessages: [TestAnim_C_15] Hello
LogBlueprintUserMessages: [TestAnim_C_16] Hello
LogBlueprintUserMessages: [TestAnim_C_17] Hello
LogBlueprintUserMessages: [TestAnim_C_18] Hello
LogBlueprintUserMessages: [TestAnim_C_19] Hello
LogBlueprintUserMessages: [TestAnim_C_20] Hello
LogBlueprintUserMessages: [TestAnim_C_21] Hello
LogBlueprintUserMessages: [TestAnim_C_22] Hello
LogBlueprintUserMessages: [TestAnim_C_23] Hello
LogBlueprintUserMessages: [TestAnim_C_24] Hello
LogBlueprintUserMessages: [TestAnim_C_25] Hello
LogBlueprintUserMessages: [TestAnim_C_26] Hello
LogBlueprintUserMessages: [TestAnim_C_27] Hello
LogBlueprintUserMessages: [TestAnim_C_28] Hello
LogBlueprintUserMessages: [TestAnim_C_29] Hello
LogBlueprintUserMessages: [TestAnim_C_30] Hello
LogBlueprintUserMessages: [TestAnim_C_31] Hello
LogBlueprintUserMessages: [TestAnim_C_32] Hello
LogBlueprintUserMessages: [TestAnim_C_33] Hello
LogBlueprintUserMessages: [TestAnim_C_34] Hello
LogBlueprintUserMessages: [TestAnim_C_35] Hello
LogBlueprintUserMessages: [TestAnim_C_36] Hello
LogBlueprintUserMessages: [TestAnim_C_37] Hello

Hi lpc35,

As you currently have it implemented, this is expected behavior.

Please use an IsValid check on Get Gawn Owner off of either Update or Initialize Animation nodes in AnimBP. This will stop any nodes after that from firing unless there’s an actual Pawn active.

-Matt W.

Hi Matt,

I added your suggestion and it seems to work. Still if I’m moving the start location of my character in the scene, this event is triggered. Please note that this behaviour does not happen under UE4.13. Also, I would like to understand why this event is triggered when I pass my mouse in the content browser on UE4.12.

Actually I’m writing a network plugin that inherit from AnimInstance, and I need a place/event where I can connect to the server. As there is no BeginPlay event in Animation Blueprint, I used this Event Blueprint Initialize Animation to proceed to the connection. I’m pretty sure it’s not the best practice but I’ve found no documentation nor thread on the forum that explain the underlying functioning of this event in the Animation Blueprint. I’m also missing an Event Blueprint UNInitialize Animation to drop the server connection… Some details about the implementation in the Engine would be very much appreciated!

Thank you very much for your time. BR

Apologies, I remember we had originally deemed it expected behavior, but then investigated it under UE-34636.

I’m no networking expert, but that doesn’t sound like a good way to do it. This would be a better question for the forums as this bug report is resolved.

-Matt W.

Hi again,

I noticed that this bug has been fixed in 4.13. Unfortunately, we have a lot of customers that still uses our plugin for project that uses < UE4.13. Do you have any workaround I can add to my plugin code to avoid this bug? Unfortunately the “Try Get Pawn Owner” is not a consistent solution for us as it modify how the AnimBlueprint works.

BR.

The IsValid? check is the only way that I know of to work around this issue. The reason it occurred in 4.13 is because the live thumbnails would initialize the AnimBP and the only way around that was to do the IsValid? check on a pawn because the Thumbnail preview has no valid pawn to reference. I’ll ask one of our Engineers if they know another way.

-Matt W.