Advertisement
Guest User

memorytest.lua

a guest
Dec 27th, 2014
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.84 KB | None | 0 0
  1. local str = ""
  2.  
  3. local gpu = component.list("gpu")()
  4. local screen = component.list("screen")()
  5. component.invoke(gpu, "bind", screen)
  6. local comp = computer
  7. do
  8.   local w,h = component.invoke(gpu, "getResolution")
  9.   component.invoke(gpu, "fill", 1, 1, w, h, " ")
  10. end
  11. gpu = component.proxy(gpu)
  12.  
  13. function update()
  14.   local free = comp.freeMemory()
  15.   gpu.set(1, 1, "Memory used: " ..  (comp.totalMemory()-free).."                   ")
  16.   gpu.set(1,2 ,"Memory free: " .. free.."            ")
  17.   gpu.set(1,3,"Total: " .. #str .. "         ")
  18. end
  19. update()
  20.  
  21. while true do
  22.   if comp.freeMemory() < 10 then
  23.     gpu.set(1, 5, "Memory low! " ..comp.freeMemory())
  24.     while comp.pullSignal() ~= "key_up" do end
  25.     gpu.set(1, 5, "                                            ")
  26.   end
  27.   str = str .. "A"
  28.   if (#str % 100) == 0 then
  29.     update()
  30.     comp.pullSignal(0.05)
  31.   end
  32. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement