In SDK 4.4, C++ calls tscript method to have memory leak
xiaoliang314 opened this issue · comments
In Windows 10.
Example of using ulayered:
ulayered.cpp add code:
class frame: public sciter::window {
public:
frame() : window( SW_MAIN | SW_ENABLE_DEBUG | SW_ALPHA | SW_GLASSY, wrc) { SetTimer(get_hwnd(), 200, 0, NULL); }
char *build_random_hexs()
{
static char hex_chars[100];
sprintf(hex_chars, "%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x\n",
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256,
rand() % 256);
return hex_chars;
}
virtual LRESULT on_message(HWINDOW hwnd, UINT msg, WPARAM wParam, LPARAM lParam, SBOOL& pHandled)
{
if (msg == WM_TIMER && wParam == 200)
{
for (int i = 0; i < 64; i++)
{
call_function("do_test", build_random_hexs());
}
}
return window::on_message(hwnd, msg, wParam, lParam, pHandled);
}
BEGIN_FUNCTION_MAP
FUNCTION_0("architecture", architecture);
END_FUNCTION_MAP
int architecture() {
// this function is here just for the demo purposes,
// it shows native function callable from script as view.architecture();
#if defined(TARGET_32)
return 32;
#elif defined(TARGET_64)
return 64;
#endif
}
};
default.htm add empty function:
function do_test(arg)
{
}
Run the program and you will see the memory keep increasing in the task manager.