Skip to content

Commit a37a516

Browse files
committed
memory leak fix
removed _function_names and _event_names ContractEvents and ContractFunctions have not used lists _event_names / _function_names. Each time a contract is created through the factory method, the _event_names list and the _function_names list are extended. Creating many contract's results in high memory usage. (cherry picked from commit 94b8b40)
1 parent 8e204ed commit a37a516

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

web3/contract.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,14 +101,11 @@ class ContractFunctions:
101101
"""Class containing contract function objects
102102
"""
103103

104-
_function_names = []
105-
106104
def __init__(self, abi, web3, address=None):
107105
if abi:
108106
self.abi = abi
109107
self._functions = filter_by_type('function', self.abi)
110108
for func in self._functions:
111-
self._function_names.append(func['name'])
112109
setattr(
113110
self,
114111
func['name'],
@@ -148,14 +145,11 @@ class ContractEvents:
148145
"""Class containing contract event objects
149146
"""
150147

151-
_event_names = []
152-
153148
def __init__(self, abi, web3, address=None):
154149
if abi:
155150
self.abi = abi
156151
self._events = filter_by_type('event', self.abi)
157152
for event in self._events:
158-
self._event_names.append(event['name'])
159153
setattr(
160154
self,
161155
event['name'],

0 commit comments

Comments
 (0)