コード例 #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();
            }
        }
コード例 #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");
            }
        }
コード例 #3
0
ファイル: MemoryConstraint.cs プロジェクト: BlackNecro/Eluant
        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");
            }
        }
コード例 #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");
            }
        }
コード例 #5
0
ファイル: MemoryConstraint.cs プロジェクト: BlackNecro/Eluant
        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();
            }
        }