Skip to content

Instantly share code, notes, and snippets.

@ironpythonbot
Created September 28, 2013 00:57
Show Gist options
  • Save ironpythonbot/6737210 to your computer and use it in GitHub Desktop.
Save ironpythonbot/6737210 to your computer and use it in GitHub Desktop.
CodePlex Issue #18722 Plain Text Attachments
from System import GC
class C(object):
_instance = None
def __new__(cls):
if C._instance is None:
C._instance = object.__new__(cls)
return C._instance
def __del__(self):
print 'deleting object with id', id(self)
c = C()
print 'created a C with id', id(c)
d = C()
print 'created another C with id', id(d)
for _ in range(3):
GC.Collect()
GC.WaitForPendingFinalizers()
print id(c), id(d)
print c
print d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment