Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
UrlLoader not enough memory — Gideros Forum

UrlLoader not enough memory

foldedfolded Member
edited January 2014 in Bugs and issues
Hi.

I'm trying to load files from server with UrlLoader, and somehow "not enough memory" pops up on a certain file.


A source code with actual URL is as follows. (You can download the file at URL.)

--------------------------------------------------

function func(event)
print(#event.data)
end


-- please get rid of -s in the URL. I'm not supposed to post an link here.

loader = UrlLoader.new("http://175.207.4.34/test/test.bin");



loader:addEventListener(Event.COMPLETE,func);

--------------------------------------------------


Using io.read also makes same error. Here is a sample.


--------------------------------------------------

function load(filename)
local file = io.open(filename,"rb")
if file==nil then
return {}
else
local result = file:read("*all")
file:close()
return result
end
end

--------------------------------------------------


I'v tested file's size and a file size is between 5111792 bytes and 5242863 bytes can't be read by UrlLoader.
Once you read the file bigger then 5242863 successfully, you can read a file which size is in the zone (5111792 ~ 5242863) as long as you don't rerun the Gideros player.

Comments

  • ar2rsawseenar2rsawseen Maintainer
    edited November 2013
    @folded indeed, seems like a bug with a internal buffer size.
    Currently I can't tell if it is on Gideros side or Lua/environment side
    But what you can do instead for now is to read with smaller buffer like:
    local function copy(src, dst)
    	local srcf = io.open(src, "rb")
    	local dstf = io.open(dst, "wb")
    	local size = 2^13      -- good buffer size (8K)
    	while true do
    		local block = srcf:read(size)
    		if not block then break end
    		dstf:write(block)
    	end
    	srcf:close()
    	dstf:close()
    end
    or use lua socket for URLs (attached example, but you may need to re-add lua socket files to project, depending on your OS and Gideros installation path)

    zip
    zip
    Test.zip
    2K
  • Thanks for your answer. Hope it would be fixed soon.
  • bysregbysreg Member
    edited January 2014
    Has there been any news about this?
  • Same problem. Not fixed?
Sign In or Register to comment.