Oleg2339798 Posted December 5, 2015 Share Posted December 5, 2015 Hi, when i use this code Lua memory shows about 76mb, while file is just 33 Code: local open = fileOpen(name) local readbyte = fileRead( open, fileGetSize ( open )) local k = base64Decode(teaDecode( readbyte, Pass )) local f = fileCreate("temp") fileWrite(f, k) fileClose(f) k=nil readbyte=nil fileClose(open) fileDelete("temp") Where could be the problem? Link to comment
killeryoyo Posted December 5, 2015 Share Posted December 5, 2015 when the script enters the server and runs. It becomes bigger in size. Not because they are 33 mb so they wont be bigger. There is scripts that are 2kb in size but when u put it and loads. it be 30 kb, so there is a difference in size. Link to comment
Oleg2339798 Posted December 5, 2015 Author Share Posted December 5, 2015 So I ask, where can script store these 90 MB, when all the variables I zeroed Link to comment
Oleg2339798 Posted December 5, 2015 Author Share Posted December 5, 2015 Add: size increases only after runing script, so there are place where data in not cleared Link to comment
Jusonex Posted December 5, 2015 Share Posted December 5, 2015 This is caused by the way Lua strings are represented in memory. To be able to deal with big files, you have to split them into small chunks as follows: local file = fileOpen("bigfile.dat") local size = fileGetSize(file) -- Get number of chunks needed (50 KB chunk size) local chunkSize = 50000 local numChunks = math.ceil(size / chunkSize) -- Read until the end is reached while not fileIsEOF(file) do local readBytes = fileRead(file, chunkSize) local decrypted = base64Decode(teaDecode(readBytes , Pass)) fileWrite(otherFile, decrypted) end You have to split the base64Encode and teaEncode calls on the input files as well though. Link to comment
Oleg2339798 Posted December 6, 2015 Author Share Posted December 6, 2015 i have the problem. I encoded with similar code and all was ok, when i try to decode it saves just 80kb Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now