You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I use the KnowledgeEngine as my Rule Engine. but the instance Of Light() ect would not actually release in memory.
I use it with a loop and at least 10000 user which has a large number Fact. The amount of memory will raise very quickly and be killed because of the memory is not enough.
Try to use gc.collect(). But it has the same result. And I need some help about that. Thanks.
This is my test sample of Light() has not be release in memory after the loop. And I use objgraph package for checking it .
# here's the demo code use by a loopfromrandomimportchoicefromexpertaimport*classLight(Fact):
"""Info about the traffic light."""passclassRobotCrossStreet(KnowledgeEngine):
@Rule(Light(color='green'))defgreen_light(self):
print("Walk")
@Rule(Light(color='red'))defred_light(self):
print("Don't walk")
@Rule(AS.light<<Light(color=L('yellow') |L('blinking-yellow')))defcautious(self, light):
print("Be cautious because light is", light["color"])
deftest_func():
engine=RobotCrossStreet()
engine.reset()
engine.declare(Light(color=choice(['green', 'yellow', 'blinking-yellow', 'red'])))
engine.run()
# will do some record..if__name__=='__main__':
importobjgraphobjgraph.show_growth()
foriinrange(10):
test_func()
print('======after======')
objgraph.show_growth()
# the first print of show_growth()'''function 2389 +2389dict 1211 +1211wrapper_descriptor 1043 +1043tuple 831 +831builtin_function_or_method 789 +789method_descriptor 743 +743weakref 731 +731getset_descriptor 455 +455member_descriptor 299 +299type 231 +231'''# the second print of show_growth'''dict 1311 +100weakref 786 +55set 155 +46builtin_function_or_method 821 +32FactCapture 30 +30list 209 +29Light 32 +29 <---- heretuple 858 +27method 43 +15ChildNode 15 +15'''
The text was updated successfully, but these errors were encountered:
I use the KnowledgeEngine as my Rule Engine. but the instance Of Light() ect would not actually release in memory.
I use it with a loop and at least 10000 user which has a large number Fact. The amount of memory will raise very quickly and be killed because of the memory is not enough.
Try to use
gc.collect()
. But it has the same result. And I need some help about that. Thanks.This is my test sample of Light() has not be release in memory after the loop. And I use
objgraph
package for checking it .The text was updated successfully, but these errors were encountered: