carrerasrodrigo / Ghost.py

Webkit based scriptable web browser for python.
http://jeanphix.me/Ghost.py
29 stars 10 forks source link

inter-process c/s to eliminate memory leak ? #13

Open zcattacz opened 11 years ago

zcattacz commented 11 years ago

gh.exit() doesn't claim much memory back. a simple way to prove this:

import sys
from time import sleep
from ghost import Ghost
for i in range(0,10):
    print 'start ', i
    gh = Ghost(cache_dir='Z:/temp/')
    page, page_id = gh.create_page()
    try:
        page.open('http://taobao.com')
    except:
        print sys.exc_value
    gh.exit()
    print '>  closed ', i
    sleep(2)

its only opening 10 times the same page, the leak will eventually bog down the main process. this happens with the original Ghost.py too. It ok to scrap a few pages though.

As the current multitab version uses a C/S architecture, if it can be extended to an inter-process level. Then the process isolation can eliminate these problems for good. Especially when the user opens some poorly scripted page that halt the server, he can even forcefully restart the server, without breaking the control process.

I don't know how much effort this will take, maybe this could be a mile stone in some future release. :+1:

carrerasrodrigo commented 11 years ago

@zcattacz Ghost should free the memory when you exit the process. I can see the problem and it should't be happening let me check this weekend and see what it's the problem!