# C++ Destructor & BeginDestroy - Run only \_once\_?!

**URL:** <https://forums.unrealengine.com/t/c-destructor-begindestroy-run-only-once/310012>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [March 8, 2015, 7:48pm UTC](https://forums.unrealengine.com/t/c-destructor-begindestroy-run-only-once/310012 "2015-03-08T19:48:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_2d04b677](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2d04b677](https://forums.unrealengine.com/u/anonymous_user_2d04b677)\
**Post date:** [March 8, 2015, 7:48pm UTC](https://forums.unrealengine.com/t/c-destructor-begindestroy-run-only-once/310012/1 "2015-03-08T19:48:35Z")

</div>

Hello,

having a destructor (AMyActor::~AMyActor) and deleting an instance of the Actor in the editor calls the destructor. However, when you press Ctrl+Z (Undo), and then delete it again, the destructor is NOT called.

Steps to reproduce:

- Create new Actor in CPP
- Create Destructor (with UE\_LOG for example)
- Compile and place Actor into level
- Delete it, should call destructor
- Undo
- Delete again, destructor is ignored

// Edit: I just noticed that even that call that goes through once is unable to do most of the stuff I want to do. (For example: Destroy other actors in the level).  
So I guess there is some other function that gets called by the engine when destroying it in the editor… Right?

// Edit2: Seems like BeginDestroy() shares this problem with the destructor. It is also only called once.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2b03d27c](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2b03d27c](https://forums.unrealengine.com/u/anonymous_user_2b03d27c)\
**Post date:** [March 11, 2015, 8:37pm UTC](https://forums.unrealengine.com/t/c-destructor-begindestroy-run-only-once/310012/2 "2015-03-11T20:37:41Z")

</div>

Hey holzlag0r-

After some testing it seems that the destructor for the class is called once for each instance of the class in the level (multiple instances will call the destructor multiple times when the first one is deleted). This bug has been reported and is being tracked internally as UE-11680 for investigation.

Cheers

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_2d04b677](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_2d04b677](https://forums.unrealengine.com/u/anonymous_user_2d04b677)\
**Post date:** [March 11, 2015, 10:34pm UTC](https://forums.unrealengine.com/t/c-destructor-begindestroy-run-only-once/310012/3 "2015-03-11T22:34:10Z")

</div>

Alright, thank you!
