1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2026-03-02 03:49:30 +00:00

Mass_parse: Fix memory leak / slow performance due to over-zealous page caching

This commit is contained in:
gnosygnu
2016-12-12 09:25:06 -05:00
parent 8f68854513
commit 5e159233ab
10 changed files with 48 additions and 26 deletions

View File

@@ -50,7 +50,7 @@ public class Xomp_tmpl_cache_bldr {
// add to text_db_loader
int page_id = rdr.Read_int("page_id");
int page_redirect_id = rdr.Read_int("page_redirect_id");
Xow_page_cache_itm itm = new Xow_page_cache_itm(page_ttl, null, null); // NOTE: "null, null;" b/c GetContent in Scrib_title checks specifically for null, not empty String; DATE:2016-10-19
Xow_page_cache_itm itm = new Xow_page_cache_itm(true, page_ttl, null, null); // NOTE: "null, null;" b/c GetContent in Scrib_title checks specifically for null, not empty String; DATE:2016-10-19
itm.Set_page_ids(page_id, page_redirect_id);
text_db_loader.Add(rdr.Read_int("page_text_db_id"), itm);
cache.Add(page_ttl.Full_db(), itm);

View File

@@ -106,8 +106,9 @@ public class Xomp_parse_wkr implements Gfo_invk {
Xoa_ttl ttl = wiki.Ttl_parse(cur_ns, ppg.Ttl_bry());
// if ns changed and prv_ns is main
if (cur_ns != prv_ns) {
if (prv_ns == gplx.xowa.wikis.nss.Xow_ns_.Tid__main)
wiki.Cache_mgr().Free_mem_all(Bool_.Y); // NOTE: this clears all caches, include imglinks
// COMMENTED: cache now supports 2 levels of permanence; no need to free entire page cache to clear pages added by ifexists and the like; DATE:2016-12-12
// if (prv_ns == gplx.xowa.wikis.nss.Xow_ns_.Tid__main)
// wiki.Cache_mgr().Free_mem(Bool_.Y); // NOTE: clears all caches, include imglinks; only Main will have benefit of
prv_ns = cur_ns;
}
Xoae_page wpg = Xoae_page.New(wiki, ttl);
@@ -137,7 +138,7 @@ public class Xomp_parse_wkr implements Gfo_invk {
if (wiki.Cache_mgr().Tmpl_result_cache().Count() > 50000)
wiki.Cache_mgr().Tmpl_result_cache().Clear();
if (done_count % cleanup_interval == 0) {
wiki.Cache_mgr().Free_mem_all(Bool_.N);
wiki.Cache_mgr().Free_mem(Bool_.N);
wiki.Parser_mgr().Scrib().Core_term();
wiki.Appe().Wiki_mgr().Wdata_mgr().Clear();
}

View File

@@ -31,7 +31,7 @@ public class Xop_mediawiki_wkr {
}
public void Free_memory() {
wiki.Cache_mgr().Tmpl_result_cache().Clear();
wiki.Cache_mgr().Free_mem_all(Bool_.N);
wiki.Cache_mgr().Free_mem(Bool_.N);
wiki.Parser_mgr().Scrib().Core_term();
wiki.Appe().Wiki_mgr().Wdata_mgr().Clear();
}