9
QtWebKit 프로세스의 메모리 크기는 새로운 페이지가로드 될 때마다 증가합니다. 메모리 캐시를 청소해도 도움이되지 않습니다. 누구든지 그것을 해결하는 방법을 알고 있습니까?QtWebKit 메모리 누수에 대한 해결책이 있습니까?
이 간단한 예에서는 동작의 일정 시간 후에 충돌 : 화상의 자동 로딩 비활성 메모리 누수
from PyQt5.QtCore import QUrl
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWebKitWidgets import QWebView
from PyQt5.QtWebKit import QWebSettings
class Crawler(QWebView):
def __init__(self):
QWebView.__init__(self)
self.settings().setMaximumPagesInCache(0)
self.settings().setObjectCacheCapacities(0, 0, 0)
self.settings().setOfflineStorageDefaultQuota(0)
self.settings().setOfflineWebApplicationCacheQuota(0)
self.settings().setAttribute(QWebSettings.AutoLoadImages, False)
self.loadFinished.connect(self._result_available)
def start(self):
self.load(QUrl('http://stackoverflow.com/'))
def _result_available(self, ok):
print('got it!')
self.settings().clearMemoryCaches() # it doesn't help
self.settings().clearIconDatabase()
self.start() # next try
if __name__ == '__main__':
app = QApplication([])
crawler = Crawler()
crawler.start()
app.exec_()
정말 아닙니다. 웹킷의 다소 불만스러운 "기능"인 것으로 보입니다. (토론에 대해서는 [here] (http://qt-project.org/forums/viewthread/11105)를보십시오.) 오히려 추악한 해결책은 주기적으로 새 프로세스를 시작하여 시스템이 메모리를 회수 할 수있게하는 것입니다. – ekhumoro