nagyistge / pyv8

Automatically exported from code.google.com/p/pyv8
0 stars 0 forks source link

a python object/memory leak problem #244

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. a simple python script below will reproduct the problem

import PyV8, gc, time, traceback

ctxt = None

class JSGlobal(PyV8.JSClass):
    def add(self, x, y):
        print x+y

gc_count = 0
def InitJS():
    global ctxt
    gc.disable()
    if ctxt!=None:
        return
    ctxt = PyV8.JSContext(JSGlobal())
    ctxt.enter()
    # ExecuteJS( JAVASCRIPT_INIT )

def ExecuteJS(js):
    global gc_count, ctxt
    try:
        gc_count += 1
        if gc_count%100 == 0:
            print 'GC!!!!\n'
            print len(gc.get_objects())
            gc.collect()
            PyV8.JSEngine.collect()
        print len(gc.get_objects())
        ctxt.eval(js)
    except:
        print traceback.format_exc()

InitJS()

for i in range(1000):
    ExecuteJS('add(1,2);')
    time.sleep(0.01)

What is the expected output? What do you see instead?

every time the output of "len(gc.get_objects())" is increasing.
The gc process below is not working.
            gc.collect()
            PyV8.JSEngine.collect()
The memory usage is increasing too.
It seems that there is a object/memory leak problem.

What version of the product are you using? On what operating system?

linux + pyv8 r586

Original issue reported on code.google.com by lxc...@gmail.com on 3 May 2015 at 7:47

Attachments: