# Ref counts and instance deleting itself

**URL:** <https://forum.kirupa.com/t/ref-counts-and-instance-deleting-itself/303077>\
**Category:** flash\
**Created:** [January 13, 2010, 2:51pm UTC](https://forum.kirupa.com/t/ref-counts-and-instance-deleting-itself/303077 "2010-01-13T14:51:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![AndyZ](https://avatars.discourse-cdn.com/v4/letter/a/8dc957/32.png) [@AndyZ](https://forum.kirupa.com/u/AndyZ)\
**Post date:** [January 13, 2010, 2:51pm UTC](https://forum.kirupa.com/t/ref-counts-and-instance-deleting-itself/303077/1 "2010-01-13T14:51:42Z")

</div>

I understand the basics of reference counting but I am having trouble getting my head around one possibility.  
What happens while a class function/method is running - suppose the class instance removes the last reference to itself while executing - how does that get dealt with internally and is it dangerous?  
Perhaps while a class’ function is running a temporary extra reference is held or else the garbage collector is otherwise not allowed to delete it.

e.g.

class Something  
{  
[INDENT]function DoSomething  
{  
[INDENT]call an external function that removes last reference to this instance

some more code - (this still executes)  
[/INDENT]}  
[/INDENT]}
