mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Fix mem leak in sfntly
This commit is contained in:
parent
d4854e20ec
commit
f8d9dead20
@ -497,7 +497,7 @@ do_subset(const char *data, Py_ssize_t sz, Ptr<CharacterPredicate> &predicate) {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
font = fonts[0].Detach();
|
font = fonts[0];
|
||||||
if (font->num_tables() == 0) {
|
if (font->num_tables() == 0) {
|
||||||
PyErr_SetString(Error, "Loaded font has 0 tables.");
|
PyErr_SetString(Error, "Loaded font has 0 tables.");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -76,6 +76,21 @@ def print_stats(old_stats, new_stats):
|
|||||||
'%10s'%nsz, ' ', '%5.1f %%'%np, suffix)
|
'%10s'%nsz, ' ', '%5.1f %%'%np, suffix)
|
||||||
prints('='*80)
|
prints('='*80)
|
||||||
|
|
||||||
|
def test_mem():
|
||||||
|
load_sfntly()
|
||||||
|
from calibre.utils.mem import memory
|
||||||
|
import gc
|
||||||
|
gc.collect()
|
||||||
|
start_mem = memory()
|
||||||
|
raw = P('fonts/liberation/LiberationSerif-Regular.ttf', data=True)
|
||||||
|
calls = 1000
|
||||||
|
for i in xrange(calls):
|
||||||
|
subset(raw, (), (('a', 'z'),))
|
||||||
|
del raw
|
||||||
|
for i in xrange(3): gc.collect()
|
||||||
|
print ('Leaked memory per call:', (memory() - start_mem)/calls*1024, 'KB')
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
import sys, time
|
import sys, time
|
||||||
from calibre import prints
|
from calibre import prints
|
||||||
|
Loading…
x
Reference in New Issue
Block a user