lib/tracksperanto/buffer_io.rb in tracksperanto-1.9.4 vs lib/tracksperanto/buffer_io.rb in tracksperanto-1.9.5
- old
+ new
@@ -3,11 +3,11 @@
# BufferIO is used for writing big segments of text. When the segment is bigger than a certain number of bytes,
# the underlying memory buffer will be swapped with a tempfile
class Tracksperanto::BufferIO < DelegateClass(IO)
include Tracksperanto::Returning
- MAX_IN_MEM_BYTES = 100_000
+ MAX_IN_MEM_BYTES = 5_000_000
def initialize
__setobj__(StringIO.new)
end
@@ -38,9 +38,11 @@
return if @tempfile_in
io = __getobj__
if io.pos > MAX_IN_MEM_BYTES
tf = Tempfile.new("tracksperanto-xbuf")
tf.write(io.string)
+ io.string = ""
+ GC.start
__setobj__(tf)
@tempfile_in = true
end
end
end
\ No newline at end of file