Exemplo n.º 1
0
        public void NoMemoryErrorWhileInClr()
        {
            if (LuaRuntime.LUAJIT && IntPtr.Size == 8)
            {
                Assert.Ignore();
            }

            using (var runtime = new MemoryConstrainedLuaRuntime()) {
                Action fn = () => {
                    runtime.MaxMemoryUse = runtime.MemoryUse + 1;

                    using (var x = runtime.CreateTable()) {
                        x[1] = "This is a string that is way more than one byte long.";
                    }

                    runtime.MaxMemoryUse = long.MaxValue;
                };

                using (var callback = runtime.CreateFunctionFromDelegate(fn)) {
                    runtime.Globals["callback"] = callback;
                }

                runtime.DoString("callback()").Dispose();
            }
        }
Exemplo n.º 2
0
        public void BasicMemoryConstraint()
        {
            using (var runtime = new MemoryConstrainedLuaRuntime()) {
                runtime.MaxMemoryUse = runtime.MemoryUse + 10 * 1024 * 1024;

                // Exponentially allocate memory.
                runtime.DoString("x = '.' while true do x = x .. x end");
            }
        }
Exemplo n.º 3
0
        public void BasicMemoryConstraint()
        {
            using (var runtime = new MemoryConstrainedLuaRuntime()) {
                runtime.MaxMemoryUse = runtime.MemoryUse + 10 * 1024 * 1024;

                // Exponentially allocate memory.
                runtime.DoString("x = '.' while true do x = x .. x end");
            }
        }
Exemplo n.º 4
0
        public void BasicMemoryConstraint()
        {
            if (LuaRuntime.LUAJIT && IntPtr.Size == 8)
            {
                Assert.Ignore();
            }

            using (var runtime = new MemoryConstrainedLuaRuntime()) {
                runtime.MaxMemoryUse = runtime.MemoryUse + 10 * 1024 * 1024;

                // Exponentially allocate memory.
                runtime.DoString("x = '.' while true do x = x .. x end");
            }
        }
Exemplo n.º 5
0
        public void NoMemoryErrorWhileInClr()
        {
            using (var runtime = new MemoryConstrainedLuaRuntime()) {
                Action fn = () => {
                    runtime.MaxMemoryUse = runtime.MemoryUse + 1;

                    using (var x = runtime.CreateTable()) {
                        x[1] = "This is a string that is way more than one byte long.";
                    }

                    runtime.MaxMemoryUse = long.MaxValue;
                };

                using (var callback = runtime.CreateFunctionFromDelegate(fn)) {
                    runtime.Globals["callback"] = callback;
                }

                runtime.DoString("callback()").Dispose();
            }
        }