Skip to content

Ch3 Memory Management, Smart Pointers and Debugging

  • Managed Memory :

  • allocate memory there’s several ways to perform it
  • NewObject<>
  • ConstructObject<>
  • SpawnActor

can be found more in docs

  • de-allcate memory object can be destroyed by calling member function of it

    • this->ConditionalBeginDestroy()
  • smart pointers

    • TSharedPtr : A thread-safe reference-counter pointer indicates a share object
    • TAutoPtr : A non-thread-safe pointer
    • TScopedPointer example
      TSharedPtr<MyClass>sharedPtr(new MyClass());
      
  • garbage collection GetWorld()->ForceGarbageCollection(true)

#include <stdio.h>

int main(int argc, char** argv)
{
    for (int i =0; i <10 ; i++)
        printf("%d \n", i);
}