Blueprint - onSwitch Function Memory Allocation

I have a Function Library that has multiple pure functions that each have 1 local variable that it performs a small script on using inputs and returns an output.

Then I have another function in the same library that starts with a switch on enum. each output on the switch calls one of the multiple pure functions.

My question is when this primary function is called are all of the pure functions allocated memory or just the one that is used after the switch?

Bump

Does every one of the pure functions get allocated memory? or only the one that is used in the switch?

Only the attached pure function is called when the corresponding return node is hit.

The blueprint execution is as follows: When you hit a node with an execution pin everything attached to its parameters is called/retrieved and the node is executed. All return parameters are stored and can be later retrieved by other execution nodes without triggering it again. (pure functions are executed on every execution node they are input of)

However, the actual memory allocations in game engines are really tricky to talk about especially when you have garbage collector involved… I know the whole library object is loaded in memory (all functions are in memory too even if you use only one of them). However, I don’t think the pure function’s local variables are allocated. I might be wrong on this one as there are often various optimizations made especially to avoid large memory allocations at runtime. (in game engines in general and probably Unreal)

This has nothing to do with the switch though. The switch only makes the execution transfer to the return node and it’s only parameter is an int.

Hope my limited knowledge helps.

Thank you. Hopefully someone can provide more information on this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.