This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients
Date 2001-02-23.18:59:17
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
# When Pickler.object is used for dump typles into file and Unpickler for load
# from files. A loaded object are not garbage collected.  When function
# dump(object,file) is used Unpickler works fine.  Problem is in pickle and
# cPickle module tested on Python 2.0 Red Hat Linux 6.2

import gc 

def main():
    fp = open('/tmp/xxx', 'w') 
    pic = pickle.Pickler(fp, 1)                   # ERROR 

    for i in range(10000):
        pickle.dump(([long(i), long(i), long(i), long(i)], i), fp) 
        # this is OK 
        pic.dump(([long(i), long(i), long(i), long(i)], i))
        # Memory leak 

    fp.close() 
    gc.set_debug(gc.DEBUG_STATS) 

    fp = open('/tmp/xxx')

    upic = pickle.Unpickler(fp)
    try: 
        while 1: 
            gc.collect() 
            print upic.load() 
    except EOFError: 
        pass

    fp.close()


if __name__ == '__main__':
    import sys
    if len(sys.argv) > 1:
        import cPickle
        pickle = cPickle
    else:
        import pickle

    main()
History
Date User Action Args
2007-08-23 13:52:54adminlinkissue229810 messages
2007-08-23 13:52:54admincreate