2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00

Merge pull request #428 from chrox/master

explicitly call free method of Blitbuffer for credocument
This commit is contained in:
Qingping Hou 2014-01-02 09:39:56 -08:00
commit f1b5c439dd
3 changed files with 26 additions and 24 deletions

View File

@ -151,6 +151,7 @@ function CreDocument:drawCurrentView(target, x, y, rect, pos)
tile_bb = Blitbuffer.new(rect.w, rect.h)
self._document:drawCurrentPage(tile_bb)
target:blitFrom(tile_bb, x, y, 0, 0, rect.w, rect.h)
tile_bb:free()
end
function CreDocument:drawCurrentViewByPos(target, x, y, rect, pos)

View File

@ -280,4 +280,29 @@ function Document:getPageText(pageno)
return text
end
--[[
helper functions
--]]
function Document:logMemoryUsage(pageno)
local status_file = io.open("/proc/self/status", "r")
local log_file = io.open("mem_usage_log.txt", "a+")
local data = -1
if status_file then
for line in status_file:lines() do
local s, n
s, n = line:gsub("VmData:%s-(%d+) kB", "%1")
if n ~= 0 then data = tonumber(s) end
if data ~= -1 then break end
end
status_file:close()
end
if log_file then
if log_file:seek("end") == 0 then -- write the header only once
log_file:write("PAGE\tMEM\n")
end
log_file:write(string.format("%s\t%s\n", pageno, data))
log_file:close()
end
end
return Document

View File

@ -224,8 +224,6 @@ function KoptInterface:getRFPageDimensions(doc, pageno, zoom, rotation)
end
function KoptInterface:renderPage(doc, pageno, rect, zoom, rotation, gamma, render_mode)
--DEBUG("log memory usage at renderPage")
--self:logMemoryUsage(pageno)
if doc.configurable.text_wrap == 1 then
return self:renderreflowedPage(doc, pageno, rect, zoom, rotation, render_mode)
else
@ -878,26 +876,4 @@ function KoptInterface:logReflowDuration(pageno, dur)
end
end
function KoptInterface:logMemoryUsage(pageno)
local status_file = io.open("/proc/self/status", "r")
local log_file = io.open("reflow_mem_log.txt", "a+")
local data = -1
if status_file then
for line in status_file:lines() do
local s, n
s, n = line:gsub("VmData:%s-(%d+) kB", "%1")
if n ~= 0 then data = tonumber(s) end
if data ~= -1 then break end
end
status_file:close()
end
if log_file then
if log_file:seek("end") == 0 then -- write the header only once
log_file:write("PAGE\tMEM\n")
end
log_file:write(string.format("%s\t%s\n", pageno, data))
log_file:close()
end
end
return KoptInterface