Re: [MBS] HTMLViewer.EvaluateJavaScriptMBS memory Leak?

2012-02-04 Thread Christian Schmitz

Am 04.02.2012 um 17:39 schrieb Michael Diehr:

 Hi Christian,
 
 I've discovered what I believe is a small but troubling memory leak in the 
 method 
 HTMLViewer.EvaluateJavaScriptMBS on mac and the corresponding function 
 IERunJavaScriptMBS.

Okay, could you make a sample project reproducing it?

I can't reproduce it here easily, but that may be due the setup with 12.1pr1 
plugins, RS 2011r4 and Mac OS X 10.7.2.

 In tests where I call either function about 50 times per second with small 
 commands, I'm seeing leaks that can be as fast as 100KB/second.   The 
 commands are short javascript functions which query the play status of a 
 plugin (flash or quicktime or html5 video).

Well, NSAutoreleasePoolMBS class exists and may be useful on Mac if that is due 
to a pool not being cleared.

 Since it's leaking on both Mac and Windows when querying either SWF or 
 QuickTime or HTML5 video objects, this suggests to me that like the leak may 
 be in MBS, rather than, say a leak in IE or WebKit or just Flash or QuickTime 
 plugins.

You can use Instruments.app (coming with Xcode) to find the source of the leak.

 * can you see an obvious place in your code where the leak is happening?  

No.

 * can you fix it?

No.

 * if so, can I pay you to make a custom build of 10.1 (I need to issue a 
 quick update of my software to fix this and prefer to not update to a later 
 MBS for obvious unit-test reasons).

We could discuss that off list, but I bet it'll be a lot of work.

 n.b.:  the leaked memory appears to be released if I reload a blank page in 
 the HTMLViewer (on mac) or if I issue htmlViewer.close (win32).   Although 
 this is a workaround for the leak, there are cases where it's not practical 
 to reload the page as some customers expect the software to be running 24/7 
 without interruption.


Not sure what you do, but you could at least measure free memory with other 
plugin functions.
So you could warn user or restart app when memory is low and you have a chance 
to do so.

Greetings
Christian

-- 
See you in Orlando, Florida for Real World 2012

More details and registration here:
http://www.realsoftware.com/community/realworld.php



___
Mbsplugins_monkeybreadsoftware.info mailing list
mbsplugins@monkeybreadsoftware.info
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info


Re: [MBS] HTMLViewer.EvaluateJavaScriptMBS memory Leak?

2012-02-04 Thread Michael Diehr
On Feb 4, 2012, at 12:12 PM, Christian Schmitz wrote:

 
 Am 04.02.2012 um 17:39 schrieb Michael Diehr:
 
 Hi Christian,
 
 I've discovered what I believe is a small but troubling memory leak in the 
 method 
 HTMLViewer.EvaluateJavaScriptMBS on mac and the corresponding function 
 IERunJavaScriptMBS.
 
 Okay, could you make a sample project reproducing it?

It's very easy to reproduce (sent you a project offlist).

this will do it:

Timer1.action
  dim s as string = htmlviewer1.EvaluateJavaScript(return 
'';)

The speed of the leak seems proportional to the size of the string returned.  
So my guess is that the string being returned from javascript to RB is not 
being freed ever.


 I can't reproduce it here easily, but that may be due the setup with 12.1pr1 
 plugins, RS 2011r4 and Mac OS X 10.7.2.


Tested and leaking with 10.6.8 and MBS 12.1pr1


 In tests where I call either function about 50 times per second with small 
 commands, I'm seeing leaks that can be as fast as 100KB/second.   The 
 commands are short javascript functions which query the play status of a 
 plugin (flash or quicktime or html5 video).
 
 Well, NSAutoreleasePoolMBS class exists and may be useful on Mac if that is 
 due to a pool not being cleared.
 
 Since it's leaking on both Mac and Windows when querying either SWF or 
 QuickTime or HTML5 video objects, this suggests to me that like the leak may 
 be in MBS, rather than, say a leak in IE or WebKit or just Flash or 
 QuickTime plugins.
 
 You can use Instruments.app (coming with Xcode) to find the source of the 
 leak.
 
 * can you see an obvious place in your code where the leak is happening?  
 
 No.
 
 * can you fix it?
 
 No.
 
 * if so, can I pay you to make a custom build of 10.1 (I need to issue a 
 quick update of my software to fix this and prefer to not update to a later 
 MBS for obvious unit-test reasons).
 
 We could discuss that off list, but I bet it'll be a lot of work.

let's see how it goes?

 
 n.b.:  the leaked memory appears to be released if I reload a blank page in 
 the HTMLViewer (on mac) or if I issue htmlViewer.close (win32).   Although 
 this is a workaround for the leak, there are cases where it's not practical 
 to reload the page as some customers expect the software to be running 24/7 
 without interruption.
 
 
 Not sure what you do, but you could at least measure free memory with other 
 plugin functions.
 So you could warn user or restart app when memory is low and you have a 
 chance to do so.

unfortunately it's an automated process that runs w/o user intervention.


 
 Greetings
 Christian
 
 -- 
 See you in Orlando, Florida for Real World 2012
 
 More details and registration here:
 http://www.realsoftware.com/community/realworld.php
 
 
 
 ___
 Mbsplugins_monkeybreadsoftware.info mailing list
 mbsplugins@monkeybreadsoftware.info
 https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

___
Mbsplugins_monkeybreadsoftware.info mailing list
mbsplugins@monkeybreadsoftware.info
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info


Re: [MBS] HTMLViewer.EvaluateJavaScriptMBS memory Leak?

2012-02-04 Thread Michael Diehr
On Feb 4, 2012, at 2:38 PM, Michael Diehr wrote:
 [...]
 Timer1.action
  dim s as string = htmlviewer1.EvaluateJavaScript(return 
 '';)
 
 The speed of the leak seems proportional to the size of the string returned.  
 So my guess is that the string being returned from javascript to RB is not 
 being freed ever.

More testing ...  these two different javascript commands both leak at the same 
speed, so I think perhaps it's the string being passed in to the command that 
leaks, not the string being returned:

Timer1.action  
  static xxx as string // a long string to leak memory faster
  if xxx =  then  // initialize first time only
for i as integer = 1 to 1000
  xxx = xxx + 0
next
  end if
  
  if Keyboard.AsyncShiftKey then // toggle the shift key at runtime to test 
options
cmd = var x = ' + xxx + '; return '' ;
  else
cmd = return ' + xxx + ';
  end if

  result = htm.EvaluateJavaScriptMBS(cmd)
___
Mbsplugins_monkeybreadsoftware.info mailing list
mbsplugins@monkeybreadsoftware.info
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info