lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I've got a sample code here:

You can switch line 24 and 25 back and forth to see the problem, as
using FFI 2D VLA here making the memory usage growth very fast, while
using plain Lua table everything is fine. I believe the problem is at
line 33. As I remembered, Mike said the line is actually implemented

 local tmp1 = array2d[y]
 local tmp2 = x*csize
 tmp1[x] = tmp2

would those two temporaries be the source of this massive growth of
memory usage? I also tried to use 1D VLA here, which really kept at a
low memory usage for a long period of time. What to worry about is not
the speed of execution here, but the often delay caused by too-often
massive garbage collection.

I originally ran into a possibly-related problem here:
(please look for line 395)

And I added that px, py instead of using x, y directly (as you can see
now in the code above), memory usage simply goes back to normal. if
you took out the px/py and using using x and y directly in the
following line, the memory usage just accumulate like crazy. Since
this code is not trivial and clear enough for a bug report (it's
rather ugly, and used OpenGL / SDL through FFI, has a long comment to
read ahead), I didn't know how to report this situation, so I came up
with the sample code in the beginning of this post, however this
seemingly mysterious problem isn't that easy to replicate in simple
code, but then that sample script got its own problem. I just felt
these 2 are somehow connected, as they are both FFI-related, and both
context used 2D VLA.

Hope Mike or somebody can help me out again here :)

Johnson Lin