Announcement

Collapse
No announcement yet.

Destructors in UE

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Destructors in UE

    Do classes in UE need destructors? When I add new code via Unreal Editor it never has a destructor.

    If they're not needed, why?

    #2
    UE4 has garbage collection. That's why in most of the cases your classes should be derived from UObject. If you're using pointers and custom non-UObject classes you'll have to deal with memory cleaning yourself.
    Alone: The Untold - a story driven horror game

    Comment


      #3
      What about UObjects in which I'm dealing with pointers, is there a special way or do I simple make a normal destructor?

      Comment


        #4
        As far as pointers are UObject types and created/spawned via NewUObject/SpawnActor everything will be handled automatically. AFAIK UObjects also work fine with "new".
        You'll need destructors for classes which are not derived from UObject, assuming there's actually something to destroy.
        Alone: The Untold - a story driven horror game

        Comment


          #5
          What if I choose to create stuff that are not UObjects inside of UObjects? Is such a scenario likely to happen?

          Comment


            #6
            Yes it could happen of course. But currently you're trying to solve problems that didn't happen yet. I mean, that's all depends on how you will use this kind of class, but well, that's out of my area of knowledge now, would like to see replies on this subjects now too
            Alone: The Untold - a story driven horror game

            Comment


              #7
              Yeah, okay

              Comment


                #8
                If you want to do manual cleanup of things inside your UObject class, you can implement BeginDestroy (this is called when the object is marked for GC, but has not been deleted yet).
                Lead Programmer - UE4 Animation/Physics/Audio Team - Epic Games
                Twitter: @EpicJamesG

                Comment


                  #9
                  That's the answer I was looking for, thanks

                  Comment

                  Working...
                  X