Skip to content

Memory leaks when evaluating JS code #8

@bekbulatov

Description

@bekbulatov

Hi, this is more PyV8 issue, but I want to know your experience.

After rendering js file (about 300kb) and exiting context, PyV8 doesn't free memory. This is code demonstration.

import os, gc
import PyV8
def get_mem():
    a = os.popen('ps -p %d -o %s | tail -1' % (os.getpid(),"vsize,rss,pcpu")).read()
    a = a.split()
    return (int(a[0]), int(a[1]))

def main():
    js_code = open('bem/touch.bundles/rubric/rubric.xml.js', 'r').read().decode('utf-8')

    for i in xrange(10**5):
        with PyV8.JSContext() as ctx:
            ctx.eval(js_code)
        if i % 10000:
            PyV8.JSEngine.collect()
            gc.collect()
            print get_mem()

if __name__ == "__main__":
    main()

Output:

(744060, 20432)
(745880, 21792)
(746904, 22268)
(746904, 22572)
...
(2176496, 1061752)
(2176496, 1062116)
Traceback (most recent call last):
  File "v8test.py", line 22, in <module>
    main()
  File "v8test.py", line 15, in main
    ctx.eval(js_code)
PyV8.JSError: JSError: <CALL_AND_RETRY_LAST> Allocation failed - process out of memory

Do you use python-bem in production?
Do you have such problem?
Does PyV8 leak with django object?
Which version of PyV8, V8 do you use?

Thank you in advance for any help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions