Does UFUNCTION have impact on performance?
I have a probably silly question.
Does the UFUNCTION or UPROPERTY or USTRUCT or UENUM decorators have impact on code performance? I'm wondering, because those macros aren't required in many situations (when I don't want to use this code from blueprints etc.). I wanted to search for variables that have UPROPERTies for no reason but I'm not sure if it is worth the time spend on refactor.
Are UE perform any extra actions for properties and functions that have those decorators?
asked Aug 03 '15 at 05:37 PM in C++ Programming
It does not impact the performence as when you call those function and propeties you normally access them, what UHT does to it (since those macros are empty and does nothing in compile time) it use them to know which functions should be reflected and generates reflection code, which register information about propeties and functions in to memoery, which happens when code module (dll with your code) is loaded and does not take noticable time. Only problem with those macros is it's bounded with capabilities of reflection system, you can't use stuff that it does not know.
You don't need to use those macros if you don't want to, only required one is UCLASS() on UObject classes, but then editor won't able to see those things and some engine features require them (like timers and delegates requires reflected function), so if something does not work or crash for odd reason then check if reflecting stuff can fix it. There might be also potential GC problems as engine automaticly deletes objects that are not pointed in any reflected pointer, assuming it a forgotten garbage. I recommand you to use UPROPERTIES on all varables and structs as it let you use commands like "DisplayAll" or "GetAll" allowing to view varable current state which is useful for debuging, it's a lot better then VS watchers.
Follow this question
Once you sign in you will be able to subscribe for any updates here