[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Low memory, but where?
- From: Milan Vugdelija <milanvugdelija@...>
- Date: Mon, 30 Aug 2004 01:01:02 -0700 (PDT)
Hello,
I have a problem witch is illustrated in the following example.
Lua-API function f should return a large table. When number of entries
is small (say, 20) everything is OK, but when I put 200, program
crashes with a dialog:
---------------------------
Debug Assertion Failed!
Program: c:\lua\bin\Lua.exe
File: dbgheap.c
Line: 1044
_expression_: _CrtIsValidHeapPointer(pUserData)
---------------------------
Can anyone tell me what do I do wrong?
I understand that I should increase memory limit, but what limit and where?
I am using Microsoft Visual C++ 6.0 and Lua 5.0.2. This is a very small
console application, and you can find below whole (C and Lua) source
code. If more information needed, please let me know.
Thanks in advance.
--------------------------- C code
#ifdef DLL_EXPORTS
#define TESTDLL_API __declspec(dllexport)
#else
#define TESTDLL_API __declspec(dllimport)
#endif
extern "C"
{
#include <stdio.h>
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
}
extern "C" TESTDLL_API int l_openTheLib(lua_State *L);
static int l_f(lua_State *L)
{
int n=200, i=0;
const char *s=lua_tostring(L,1);
lua_newtable(L);
for (i=1;i<=n;i++)
{
lua_pushnumber(L, i);
lua_pushstring(L, s);
lua_settable(L, -3);
//printf("%d\n",lua_gettop(L));
}
return(1);
}
int l_openTheLib(lua_State *L)
{
lua_pushcfunction(L,l_f);lua_setglobal(L,"f");
return 0;
}
--------------------------- Lua code
sDLLName="Debug\\dll.dll"
openTheLib = loadlib(sDLLName, "l_openTheLib")
assert(openTheLib)
openTheLib()
t=f("A"); for i,v in t do print(i, v) end
t=f("B"); for i,v in t do print(i, v) end
t=f("C"); for i,v in t do print(i, v) end
Do you Yahoo!?
Win 1 of 4,000 free domain names from Yahoo! Enter now.