forked from KolibriOS/kolibrios
WebView: fixed memory leak in cache.add(), give system memory back each time parse ends
git-svn-id: svn://kolibrios.org@8425 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
7f757d3058
commit
6cb7bf1eb6
@ -304,6 +304,11 @@ void TWebBrowser::ParseHtml(dword _bufpointer, _bufsize){
|
|||||||
Paint();
|
Paint();
|
||||||
NewLine();
|
NewLine();
|
||||||
list.count = draw_y;
|
list.count = draw_y;
|
||||||
|
|
||||||
|
DrawBuf.bufh = math.max(list.visible, draw_y);
|
||||||
|
debugval("DrawBuf.bufh", DrawBuf.bufh);
|
||||||
|
buf_data = realloc(buf_data, DrawBuf.bufh * DrawBuf.bufw * 4 + 8);
|
||||||
|
|
||||||
list.CheckDoesValuesOkey();
|
list.CheckDoesValuesOkey();
|
||||||
anchors.current = NULL;
|
anchors.current = NULL;
|
||||||
custom_encoding = -1;
|
custom_encoding = -1;
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
// DATA //
|
// DATA //
|
||||||
// //
|
// //
|
||||||
//===================================================//
|
//===================================================//
|
||||||
char version[]="WebView 3.04";
|
char version[]="WebView 3.06";
|
||||||
|
|
||||||
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
|
#define DEFAULT_URL URL_SERVICE_HOMEPAGE
|
||||||
|
|
||||||
@ -231,10 +231,12 @@ void main()
|
|||||||
if (http_get_type==PAGE) {
|
if (http_get_type==PAGE) {
|
||||||
history.add(http.cur_url);
|
history.add(http.cur_url);
|
||||||
cache.add(http.cur_url, http.content_pointer, http.content_received, PAGE);
|
cache.add(http.cur_url, http.content_pointer, http.content_received, PAGE);
|
||||||
LoadInternalPage(http.content_pointer, http.content_received);
|
free(http.content_pointer);
|
||||||
|
LoadInternalPage(cache.current_buf, cache.current_size);
|
||||||
}
|
}
|
||||||
else if (http_get_type==IMG) {
|
else if (http_get_type==IMG) {
|
||||||
cache.add(cur_img_url, http.content_pointer, http.content_received, IMG);
|
cache.add(cur_img_url, http.content_pointer, http.content_received, IMG);
|
||||||
|
free(http.content_pointer);
|
||||||
GetImg(false);
|
GetImg(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,9 @@ void _cache::add(dword _url, _data, _size, _type)
|
|||||||
url.add(_url);
|
url.add(_url);
|
||||||
size.add(_size);
|
size.add(_size);
|
||||||
type.add(_type);
|
type.add(_type);
|
||||||
|
|
||||||
|
current_buf = data_pointer;
|
||||||
|
current_size = _size;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool _cache::has(dword _link)
|
bool _cache::has(dword _link)
|
||||||
|
@ -54,7 +54,6 @@ void main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER + EVM_STACK);
|
||||||
@SetWindowLayerBehaviour(-1, ZPOS_ALWAYS_TOP);
|
|
||||||
loop() switch(@WaitEvent())
|
loop() switch(@WaitEvent())
|
||||||
{
|
{
|
||||||
case evMouse: edit_box_mouse stdcall (#ed); break;
|
case evMouse: edit_box_mouse stdcall (#ed); break;
|
||||||
|
@ -128,26 +128,22 @@ void DrawBufer::Show(dword _y_offset, _h)
|
|||||||
|
|
||||||
void DrawBufer::IncreaseBufSize()
|
void DrawBufer::IncreaseBufSize()
|
||||||
{
|
{
|
||||||
static dword alloc_counter;
|
|
||||||
static dword bufh_initial;
|
static dword bufh_initial;
|
||||||
dword alloc_size;
|
dword alloc_size;
|
||||||
dword free_ram_size;
|
dword free_ram_size;
|
||||||
char error_str[256];
|
char error_str[256];
|
||||||
|
|
||||||
if (!buf_data) {
|
if (!buf_data) {
|
||||||
alloc_counter = 1;
|
alloc_size = bufh * bufw * 4 + 8;
|
||||||
bufh_initial = bufh;
|
|
||||||
alloc_size = bufw * bufh * 4 + 8;
|
|
||||||
buf_data = malloc(alloc_size);
|
buf_data = malloc(alloc_size);
|
||||||
}
|
} else {
|
||||||
else {
|
if (bufh_initial != bufh) bufh_initial = bufh;
|
||||||
alloc_counter++;
|
bufh += 4096*1600/bufw; //+50 Mb
|
||||||
bufh = bufh_initial * alloc_counter;
|
alloc_size = bufh * bufw * 4 + 8;
|
||||||
alloc_size = bufw * bufh * 4 + 8;
|
|
||||||
buf_data = realloc(buf_data, alloc_size);
|
buf_data = realloc(buf_data, alloc_size);
|
||||||
Fill(alloc_counter - 1 * bufw * bufh_initial * 4 + 8, fill_color);
|
Fill(bufh_initial * bufw * 4 + 8, fill_color);
|
||||||
}
|
}
|
||||||
|
bufh_initial = bufh;
|
||||||
free_ram_size = GetFreeRAM() * 1024;
|
free_ram_size = GetFreeRAM() * 1024;
|
||||||
if (alloc_size > free_ram_size) {
|
if (alloc_size > free_ram_size) {
|
||||||
sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size - free_ram_size/1048576);
|
sprintf(#error_str, #draw_buf_not_enaught_ram, alloc_size - free_ram_size/1048576);
|
||||||
@ -156,5 +152,4 @@ void DrawBufer::IncreaseBufSize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -106,9 +106,7 @@ void load_lib()
|
|||||||
void main()
|
void main()
|
||||||
{
|
{
|
||||||
int btn;
|
int btn;
|
||||||
//dword cpu_frequency = GetCpuFrequency()/1000;
|
|
||||||
load_lib();
|
load_lib();
|
||||||
@SetWindowLayerBehaviour(-1, ZPOS_ALWAYS_TOP);
|
|
||||||
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
@SetEventMask(EVM_REDRAW + EVM_KEY + EVM_BUTTON + EVM_MOUSE + EVM_MOUSE_FILTER);
|
||||||
loop() switch(@WaitEventTimeout(50))
|
loop() switch(@WaitEventTimeout(50))
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user