Skip to content

Commit 79bbe39

Browse files
committed
Merge pull request #220 from tpaviot/review/new-ms
Memory management improvements
2 parents 2bca547 + c3c0b80 commit 79bbe39

File tree

230 files changed

+24188
-74781
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+24188
-74781
lines changed

src/GarbageCollector.py

Lines changed: 13 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -15,86 +15,38 @@
1515
##You should have received a copy of the GNU Lesser General Public License
1616
##along with pythonOCC. If not, see <http://www.gnu.org/licenses/>.
1717

18-
# Init logging system
19-
from collections import deque
18+
import warnings
19+
warnings.warn("Deprecation Warning: do not use the GarbageCollector anymore, it is unneeded.")
2020

2121

2222
class GarbageCollector(object):
23-
""" Garbage collector for OCC objects
23+
""" DEPRECATED. Garbage collector for OCC objects
2424
"""
2525
def __init__(self):
26-
#self._collected_objects = []
27-
self._handles = deque()
28-
self._transients = deque()
29-
self._misc = deque()
30-
31-
# The list for the prevented objects
32-
self._prevent = deque()
33-
34-
# define contexts lists
35-
self._handles_contexts = deque()
36-
self._transients_contexts = deque
37-
self._misc_contexts = deque()
26+
pass
3827

3928
def prevent_object(self, obj):
40-
''' Prevent an object from being deleted. This object is temporary
29+
''' DEPRECATED. Prevent an object from being deleted. This object is temporary
4130
stored in a list to increase its refecount.
4231
'''
43-
self._prevent.append(obj)
32+
pass
4433

4534
def push_context(self):
46-
''' Create a new context. When the push context method is called,
35+
''' DEPRECATED. Create a new context. When the push context method is called,
4736
objects are collected in this new context. When the context is popped,
4837
erase the content of the context.
4938
'''
50-
# store the current objects in the contexts list
51-
self._handles_contexts.append(self._handles)
52-
self._transients_contexts.append(self._transients)
53-
self._misc_contexts.append(self._misc)
54-
# Then erase the content of the current lists
55-
self._handles = deque()
56-
self._transients = deque()
57-
self._misc = deque()
39+
pass
5840

5941
def pop_context(self):
60-
self._handles = self._handles_contexts.pop()
61-
self._transients = self._transients_contexts.pop()
62-
self._misc = self._misc_contexts.pop()
42+
pass
6343

6444
def collect_object(self, obj_deleted):
65-
''' This method is called whenever a pythonOCC instance is deleted.'''
66-
if hasattr(obj_deleted, 'was_purged'):
67-
return False
68-
if obj_deleted.__class__.__name__.startswith('Handle'):
69-
self._handles.append(obj_deleted)
70-
elif hasattr(obj_deleted, "GetHandle"):
71-
self._transients.append(obj_deleted)
72-
else:
73-
self._misc.append(obj_deleted)
45+
''' DEPRECATED. This method is called whenever a pythonOCC instance is deleted.'''
46+
pass
7447

7548
def smart_purge(self):
76-
# TODO: need to reverse the lists first in order
77-
# to start with the olders objects?
78-
# Remove Handles
79-
while len(self._handles) > 0:
80-
handle = self._handles.pop()
81-
handle.Nullify() # decrement ref counting_kill_pointed()
82-
# after that, the reference counting of transients objects
83-
# in the garbage should be 0
84-
handle.was_purged = True
85-
# Remove Transients
86-
for transient in list(self._transients):
87-
transient_must_be_purged = False
88-
if transient.GetRefCount() == 0:
89-
transient_must_be_purged = True
90-
if transient_must_be_purged:
91-
#transient._kill_pointed()
92-
transient.was_purged = True
93-
self._transients.remove(transient)
94-
# Remove other objects
95-
while len(self._misc) > 0:
96-
misc = self._misc.pop()
97-
misc._kill_pointed()
98-
misc.was_purged = True
49+
# DEPRECATED.
50+
pass
9951

10052
garbage = GarbageCollector()

0 commit comments

Comments
 (0)