Download

AddStaticMeshComponent(BP) vs NewObject (C++) Slower Performance?

https://answers.unrealengine.com/questions/228335/addstaticmeshcomponentbp-vs-newobject-c-slower-per.html

I have recently converted my BP code to C++ and one thing I see different is the behavior of creating static meshes. In Blueprint when you create a mesh with AddStaticMeshComponent this instance is auto cleared on the re-entry of the construction function. But in C++ this does not happen causing you to manually delete these objects causing slower construction. Unless there is a looser construct process that I’m missing. I’m trying some other construction types but they all seem to keep the object around after the initial creation in the constructor.

Has anyone else seen this to be true? Maybe there is a faster process for clearing static mesh? Of maybe the way that they create a mesh with AddStaticMeshComponent has a weak reference so it can be better cleared? … I’m looking though the docs now for faster processes but before when Dragging out a spline I create meshes along the spline but in BP its a fast process but in C++ its slower to do this process. I’m not really understanding why…

This is the process in BP for the proxy gen but in c++ this same process is so slow. Will keep researching.

I found this which deletes the objects automatically this increated the performance but it’s still slower than the BP creation:

		tmpMesh->CreationMethod = EComponentCreationMethod::SimpleConstructionScript;

Looking more into the TOT of the createion process…

Hello, thx for the method i was looking for something like this. Have you tried with ConstructObject function?

I’ll check the speed of this one. I did find that NewObject is the slowest and more reliable of the creation functions. Ill try that.