Memory leak in Windows clipboard handling

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Memory leak in Windows clipboard handling

Henrik Sperre Johansen

In sqWin32Window.c, function clipboardWriteFromAt

The line

  /* allocate temporary storage and copy string (inserting Lfs) */
  cvt = tmp = malloc(utf8Count+1);

cvt is not released before function returns.

Should be safe to do so after its use in

/* Convert data to Unicode UTF16. */
  MultiByteToWideChar( CP_UTF8, 0, cvt, -1, out, wcharsNeeded );


To reproduce:
Write a large string in a workspace (say, 1MB of ascii chars), then repeatedly copy it.
Squeak.exe's memory usage will grow, not released when doing garbage collection.

Cheers,
Henry
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak in Windows clipboard handling

Eliot Miranda-2
 
Henrik,

    great catch!  How did you find it??

On Fri, Nov 19, 2010 at 2:08 AM, Henrik Johansen <[hidden email]> wrote:

In sqWin32Window.c, function clipboardWriteFromAt

The line

 /* allocate temporary storage and copy string (inserting Lfs) */
 cvt = tmp = malloc(utf8Count+1);

cvt is not released before function returns.

Should be safe to do so after its use in

/* Convert data to Unicode UTF16. */
 MultiByteToWideChar( CP_UTF8, 0, cvt, -1, out, wcharsNeeded );


To reproduce:
Write a large string in a workspace (say, 1MB of ascii chars), then repeatedly copy it.
Squeak.exe's memory usage will grow, not released when doing garbage collection.

Cheers,
Henry

Reply | Threaded
Open this post in threaded view
|

Re: Memory leak in Windows clipboard handling

Henrik Sperre Johansen
 
On 19.11.2010 20:53, Eliot Miranda wrote:
 


Henrik,

    great catch!  How did you find it??

By chance.
Was trying to better understand the keyboard event creation code, scrolled too far, and kept on reading :)

Cheers,
Henry
Reply | Threaded
Open this post in threaded view
|

Re: Memory leak in Windows clipboard handling

Eliot Miranda-2
 


On Fri, Nov 19, 2010 at 3:23 PM, Henrik Sperre Johansen <[hidden email]> wrote:
 
On 19.11.2010 20:53, Eliot Miranda wrote:
 


Henrik,

    great catch!  How did you find it??

By chance.
Was trying to better understand the keyboard event creation code, scrolled too far, and kept on reading :)

that's great.  You don't skim as you read but instead understand deeply.  Most impressive.

best
Eliot 

Cheers,
Henry