1. getRichText() memory leak?
- Posted by Bob Thompson <getter at ?astmai?.co.uk> May 15, 2008
- 650 views
Chris, I've noticed that the commit charge carries on increasing when getRichText() is run repeatedly using richedit50W on XP. Here's a demo. Any ideas? Regards, Bob
include Win32Lib.ew without warning --====================================================== constant win = createEx(Window, "demo", 0, 0, 0, 300, 200, 0, 0) constant tool_bar = createEx(ToolBar, "", win, 0, 0, w32Edge, 34, 0, 0) constant edit = createEx(RichEdit, "", win, 0, 0, w32Edge, {w32Edge, +34}, w32or_all({ES_NOHIDESEL}), 0) constant button1 = createEx(PushButton, "get_rich_text", tool_bar, 0, 0, 100, 30, 0, 0) constant button2 = createEx(PushButton, "clear_editor", tool_bar, 100, 0, 100, 30, 0, 0) constant button3 = createEx(PushButton, "reset_editor", tool_bar, 200, 0, 100, 30, 0, 0) setFont({button1, button2, button3}, "Arial", 9, Bold) --===================================================== sequence big_text, word big_text = {} word = {} --====================================================== for n = 1 to 1000000 do for m = 1 to 5 do word &= rand(26) + 96 end for word &= 32 big_text &= word word = {} end for setText(edit, big_text) --====================================================== procedure get_rich_text(atom self, atom event, sequence params) sequence selection selection = getRichText(edit, -1) end procedure setHandler(button1, w32HClick, routine_id("get_rich_text")) --====================================================== procedure clear_editor(atom self, atom event, sequence params) setText(edit, "") end procedure setHandler(button2, w32HClick, routine_id("clear_editor")) -- --====================================================== procedure reset_editor(atom self, atom event, sequence params) setText(edit, big_text) end procedure setHandler(button3, w32HClick, routine_id("reset_editor")) -- --====================================================== WinMain(win, Normal)
2. Re: getRichText() memory leak?
- Posted by CChris <christian.cuvier at agricultu??.gouv.fr> May 15, 2008
- 652 views
- Last edited May 16, 2008
Bob Thompson wrote: > > > Chris, > > I've noticed that the commit charge carries on increasing when getRichText() > is run repeatedly using richedit50W on XP. Here's a demo. Any ideas? > > Regards, > > Bob > > }}} <eucode> > > include Win32Lib.ew > without warning > --====================================================== > constant win = createEx(Window, "demo", 0, 0, 0, 300, 200, 0, 0) > constant tool_bar = createEx(ToolBar, "", win, 0, 0, w32Edge, 34, 0, 0) > constant edit = createEx(RichEdit, "", win, 0, 0, w32Edge, {w32Edge, +34}, > w32or_all({ES_NOHIDESEL}), 0) > constant button1 = createEx(PushButton, "get_rich_text", tool_bar, > 0, 0, 100, 30, 0, 0) > constant button2 = createEx(PushButton, "clear_editor", tool_bar, > 100, 0, 100, 30, 0, 0) > constant button3 = createEx(PushButton, "reset_editor", tool_bar, > 200, 0, 100, 30, 0, 0) > setFont({button1, button2, button3}, "Arial", 9, Bold) > --===================================================== > sequence big_text, word > big_text = {} > word = {} > --====================================================== > for n = 1 to 1000000 do > for m = 1 to 5 do > word &= rand(26) + 96 > end for > word &= 32 > big_text &= word > word = {} > end for > setText(edit, big_text) > --====================================================== > procedure get_rich_text(atom self, atom event, sequence params) > sequence selection > selection = getRichText(edit, -1) > end procedure > setHandler(button1, w32HClick, routine_id("get_rich_text")) > --====================================================== > procedure clear_editor(atom self, atom event, sequence params) > setText(edit, "") > end procedure > setHandler(button2, w32HClick, routine_id("clear_editor")) > -- --====================================================== > procedure reset_editor(atom self, atom event, sequence params) > setText(edit, big_text) > end procedure > setHandler(button3, w32HClick, routine_id("reset_editor")) > -- --====================================================== > WinMain(win, Normal) > > </eucode> {{{ I'll check for any memory leak, thanks or reporting it. CChris
3. Re: getRichText() memory leak?
- Posted by Larry Miller <larrymiller at sasktel.?et> May 15, 2008
- 630 views
- Last edited May 16, 2008
I have located the problem. It is in getData() in win32Lib.ew Locate the line "text=peek({buffer,iLength})" at about line 15382. There is more than instance of this code so be sure to get the right line. I inserted "w32release_mem( buffer )" after this line. This is in version .70.4 The memory for buffer was allocated but never freed Larry Miller
4. Re: getRichText() memory leak?
- Posted by Bob Thompson <getter at fast?ail.c?.uk> May 15, 2008
- 637 views
- Last edited May 16, 2008
Larry Miller wrote: > > I have located the problem. > It is in getData() in win32Lib.ew > > Locate the line "text=peek({buffer,iLength})" at about line 15382. There is > more than instance of this code so be sure to get the right line. > I inserted "w32release_mem( buffer )" after this line. > > This is in version .70.4 > > The memory for buffer was allocated but never freed > > Larry Miller Thanks, Larry. That sorts the problem with getRichText() in my demo but I suspect more leaks. I have a large program and it took a fair amount of ripping apart to pin the problem down to getRichText() .... but it still has more memory leaks :( Maybe it's with getStream and putStream. I'll be back. Regards, Bob
5. Re: getRichText() memory leak?
- Posted by CChris <christian.cuvier at agricult??e.gouv.fr> May 15, 2008
- 619 views
- Last edited May 16, 2008
Larry Miller wrote: > > I have located the problem. > It is in getData() in win32Lib.ew > > Locate the line "text=peek({buffer,iLength})" at about line 15382. There is > more than instance of this code so be sure to get the right line. > I inserted "w32release_mem( buffer )" after this line. > > This is in version .70.4 > > The memory for buffer was allocated but never freed > > Larry Miller Good catch! Thanks a lot. CChris