Last active
August 29, 2015 14:17
-
-
Save nramirezuy/cf6e0a41d3c7217f10a7 to your computer and use it in GitHub Desktop.
Item memory leak
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Starting memory: 19332 (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) | |
Ending memory: 19456 (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) | |
Filename: test_dclass.py | |
Line # Mem usage Increment Line Contents | |
================================================ | |
11 19.000 MiB 0.000 MiB class _DummyA(cls): | |
12 19.000 MiB 0.000 MiB pass | |
Filename: test_dclass.py | |
Line # Mem usage Increment Line Contents | |
================================================ | |
9 19.000 MiB 0.000 MiB @profile | |
10 def create_new_class(cls): | |
11 class _DummyA(cls): | |
12 19.000 MiB 0.000 MiB pass | |
13 | |
14 19.000 MiB 0.000 MiB return _DummyA |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Starting memory: 19332 (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) | |
Ending memory: 746060 (resource.getrusage(resource.RUSAGE_SELF).ru_maxrss) | |
Filename: test_with_instance.py | |
Line # Mem usage Increment Line Contents | |
================================================ | |
11 728.566 MiB 0.000 MiB class _DummyA(cls): | |
12 728.566 MiB 0.000 MiB pass | |
Filename: test_with_instance.py | |
Line # Mem usage Increment Line Contents | |
================================================ | |
9 728.566 MiB 0.000 MiB @profile | |
10 def create_new_class_and_instantiate(cls): | |
11 class _DummyA(cls): | |
12 728.570 MiB 0.004 MiB pass | |
13 | |
14 728.574 MiB 0.004 MiB _DummyA() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resource | |
from scrapy.item import Item | |
class DummyA(Item): | |
pass | |
@profile | |
def create_new_class(cls): | |
class _DummyA(cls): | |
pass | |
return _DummyA | |
def run(): | |
for _ in xrange(100000): | |
create_new_class(DummyA) | |
if __name__ == '__main__': | |
print 'Starting memory:', resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, '(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)' | |
run() | |
print 'Ending memory:', resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, '(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)' | |
print '\n\n' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import resource | |
from scrapy.item import Item | |
class DummyA(Item): | |
pass | |
@profile | |
def create_new_class_and_instantiate(cls): | |
class _DummyA(cls): | |
pass | |
_DummyA() | |
def run(): | |
for _ in xrange(100000): | |
create_new_class_and_instantiate(DummyA) | |
if __name__ == '__main__': | |
print 'Starting memory:', resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, '(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)' | |
run() | |
print 'Ending memory:', resource.getrusage(resource.RUSAGE_SELF).ru_maxrss, '(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss)' | |
print '\n\n' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment