Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leaks when evaluating JS code #8

Open
bekbulatov opened this issue Apr 10, 2014 · 0 comments
Open

Memory leaks when evaluating JS code #8

bekbulatov opened this issue Apr 10, 2014 · 0 comments

Comments

@bekbulatov
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant