|
Post by branster707 on Mar 22, 2017 18:59:38 GMT
When I run a script I made for long enough this error pops up:
"Program Break: Device memory warning
< Program Ended >"
What does this mean and how do I prevent it?
|
|
|
Post by Admin on Mar 22, 2017 19:50:04 GMT
When I run a script I made for long enough this error pops up: "Program Break: Device memory warning < Program Ended >" What does this mean and how do I prevent it? You are filling the memory of your device. Make sure to set unused variables to nil as soon as possible.
|
|
|
Post by branster707 on Mar 22, 2017 21:04:35 GMT
When I run a script I made for long enough this error pops up: "Program Break: Device memory warning < Program Ended >" What does this mean and how do I prevent it? You are filling the memory of your device. Make sure to set unused variables to nil as soon as possible. Is using table.remove the same? Im storing the variables in a table and then removing them under a certain condition, it doesnt seem to depend on how many variables are in the table. Ive tested to make sure they are actually being removed, and they are, but the error still pops up when dealing with the same amount of variables that the code had no problem running when it first started up. Here's the code if it helps: require "Mods"
draw.start()
parts = {} posx = {} posy = {} speed = 1 tim = 0
local w, h = draw.getport()
function draw.touchbegan(t) local x = t[1].x local y = t[1].y for i = 1, 360 do parts[#parts+1] = {x, y, draw.black, math.rad(i)} end end
function draw.touchmoved(t) local x = t[1].x local y = t[1].y if tim%10 == 0 then for i = 0, 360 do parts[#parts+1] = {x, y, draw.black, math.rad(i)} end tim = 0 end end
function draw.touchended(t) local x = t[1].x local y = t[1].y
end
function drawall() for i, v in pairs(parts) do draw.point(table.unpack(v)) end end
function update() for i, v in pairs(parts) do v[1] = v[1]+speed*math.cos(v[4]) v[2] = v[2]+speed*math.sin(v[4]) if v[1] >= w or v[1] <= 0 or v[2] >= h or v[2] <= 0 then table.remove(parts, i) end end end
while true do --tim = tim + 1 draw.doevents() draw.beginframe() draw.clear() update() drawall() draw.endframe() end
|
|
|
Post by cosmicfloppydisk on Mar 30, 2017 16:45:17 GMT
I went ahead an ran your code, I obviously got an error for the require 'mods' and the draw.start() but based on the fact I had no issues with that base file maybe check the mods file for a never ending while loop or the draw.start() function which I assume you made
draw.setantialias(false) draw.setscreen(2) draw.setclearcolor({.2,.2,.2,1}) draw.clearscreen() draw.showtitle(false)
parts = {} posx = {} posy = {} speed = 1 tim = 0
local w, h = draw.getport()
function draw.touchbegan(t) local x = t[1].x local y = t[1].y for i = 1, 360 do parts[#parts+1] = {x, y, draw.black, math.rad(i)} end end
function draw.touchmoved(t) local x = t[1].x local y = t[1].y if tim%10 == 0 then for i = 0, 360 do parts[#parts+1] = {x, y, draw.black, math.rad(i)} end tim = 0 end end
function draw.touchended(t) local x = t[1].x local y = t[1].y
end
function drawall() for i, v in pairs(parts) do draw.point(table.unpack(v)) end end
function update() for i, v in pairs(parts) do v[1] = v[1]+speed*math.cos(v[4]) v[2] = v[2]+speed*math.sin(v[4]) if v[1] >= w or v[1] <= 0 or v[2] >= h or v[2] <= 0 then table.remove(parts, i) end end end
while true do --tim = tim + 1 draw.doevents() draw.beginframe() draw.clear() update() drawall() draw.endframe() end
I ran just that and had no issues the circles are oddly hipnotic. Give this one a try… I removed mods and draw.start and added the standard draw screen stuff
|
|
|
Post by cosmicfloppydisk on Mar 30, 2017 16:51:01 GMT
So after playing with it I did get the same issue. I do believe since you are creating so many points, you're running out of the max allocated memory for your program that your device has allowed, maybe add a simple line to say let there only be 1000 points on the screen at once 😉
|
|
|
Post by branster707 on Mar 30, 2017 18:51:49 GMT
So after playing with it I did get the same issue. I do believe since you are creating so many points, you're running out of the max allocated memory for your program that your device has allowed, maybe add a simple line to say let there only be 1000 points on the screen at once 😉 Yeah I did think that was the problem at first, but when playing around with it i found the error even occurs when 1. It's in the process of actually removing some of the objects, and none are being created. and 2. When dealing with around the same amount of objects it was able to handle when first starting up the code.
|
|