Dear Sirs,
please try this file:
-----------------------------------------------------------
#! /usr/bin/env texlua
--*- Lua -*-
local testfile=('testfile')
local use_lpeg=false
function split (s, sep)
sep = lpeg.P(sep)
local elem = lpeg.C((1 - sep)^0)
local p = lpeg.Ct(elem * (sep * elem)^0)
return lpeg.match(p, s)
end
fh=assert(io.open(testfile, 'r'))
while true do
local line, rest = fh:read(2^13, '*line')
if not line then break end
if rest then line = line..rest end
if use_lpeg then
local tab = split(line, '\n')
else
local tab = line:explode('\n')
end
end
fh:close()
-----------------------------------------------------------
Reading the file into memory this way is extremely fast and efficient
in regard to memory consumption.
I have to split the string "line" into lines. This can be done either
by string.explode() or split().
When I use the lpeg based function split(), everything is fine, though
it's slower than string.explode(). But when I use string.explode(), I
see in xosview that memory consumption is steadily growing while the
program is running.
Regards,
Reinhard
--
----------------------------------------------------------------------------
Reinhard Kotucha Phone: +49-511-3373112
Marschnerstr. 25
D-30167 Hannover mailto:reinhard.kotucha@web.de
----------------------------------------------------------------------------
Microsoft isn't the answer. Microsoft is the question, and the answer is NO.
----------------------------------------------------------------------------