Page 1 of 1

Memory leak with MENU 2007

Posted: Sun Feb 13, 2011 12:36 am
by IBTC
Hello!

Code:

Code: Select all

FUNCTION MAIN()

   LOCAL oWnd

   SetResDebug()

   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "Test";
      MENU BuildMenu()

   ACTIVATE WINDOW oWnd

   FERASE("CHECKRES.TXT")
   CHECKRES()
   winExec("notepad .\checkres.txt")

return(0)

function BuildMenu()

   local oMenu

   MENU oMenu 2007

      MENUITEM "Item 1"

         MENU

            MENUITEM "Item 1.1"
            MENUITEM "Item 1.2"

            MENU
               MENUITEM "Item 1.2a"
               MENUITEM "Item 1.2b"
            ENDMENU

            MENUITEM "Item 1.3"

            MENU
               MENUITEM "Item 1.3a"
               MENUITEM "Item 1.3b"
            ENDMENU

         ENDMENU

   ENDMENU

return oMenu

 
Checkres.txt:

Code: Select all

02/13/11 01:35:21: BMP,1568,TWINDOW:HANDLEEVENT(0)->_FWH(3394)->SHOWWINDOW(0)->TWINDOW:ACTIVATE(961)->MAIN(29)
 
With only

Code: Select all

MENU oMenu


there is no problem.

Re: Memory leak with MENU 2007

Posted: Sun Feb 13, 2011 7:23 am
by James Bott

Re: Memory leak with MENU 2007

Posted: Sun Feb 13, 2011 7:49 am
by nageswaragunupudi
I too confirm this problem.

Mr.James
This issue was not discussed and solved in the other posting you are referring to. This is yet to be fixed.

Re: Memory leak with MENU 2007

Posted: Sun Feb 13, 2011 8:56 am
by Antonio Linares
Ruediger,

Already fixed and included for next FWH build, thanks! :-)

Re: Memory leak with MENU 2007

Posted: Sun Feb 13, 2011 9:00 am
by Richard Chidiak
Antonio

TBTNBMP does not release fonts also,

Will the fix for this class be included in next fwh release ?

Thanks

Richard

Re: Memory leak with MENU 2007

Posted: Sun Feb 13, 2011 9:40 am
by Antonio Linares
Richard,

Please comment out this entire section from Class TBtnBmp Method Paint():

Code: Select all

 /*
   if ::lBarBtn
      ::l2007 = ::oWnd:l2007
      if ::oFont == NIL
         if ::oWnd:oFont != nil
            if ::oWnd:oFont:cFaceName != "Tahoma"
               DEFINE FONT oFont NAME "Tahoma" SIZE 0, -11
               ::oWnd:SetFont( oFont )
            endif
            ::SetFont( ::oWnd:oFont )
         else
            DEFINE FONT oFont NAME "Tahoma" SIZE 0, -11
            ::SetFont( oFont )
         endif
      else
         ::oWnd:SetFont( ::oFont )
      endif
   else
      if ::oFont == nil
         ::SetFont( ::oWnd:oFont )
         if ::oFont == nil .and. ! Empty( ::oWnd )
           ::SetFont( ::oWnd:oWnd:oFont )
         endif
      else
         ::SetFont( ::oFont )
      endif
   endif
   */
 
as fonts should not be created from the Paint method, thanks

Re: Memory leak with MENU 2007

Posted: Sun Feb 13, 2011 10:06 am
by IBTC
Hi Antonio,
Antonio Linares wrote: Already fixed and included for next FWH build, thanks!
No worries. Thanks for the quick help. :D

Re: Memory leak with MENU 2007

Posted: Mon Feb 14, 2011 8:07 pm
by IBTC
Hi Antonio,
Antonio Linares wrote:Already fixed and included for next FWH build
Is it possible that the problem still exists in FWH 11.01 or maybe there is another problem?

Is still get with FWH 11.01:

Code: Select all

02/14/11 21:01:59: BMP,1568,TWINDOW:HANDLEEVENT(0)->_FWH(3408)->SHOWWINDOW(0)->TWINDOW:ACTIVATE(975)->MAIN(14)
BTW... I only have the prg file without a rc/manifest file.

Re: Memory leak with MENU 2007

Posted: Tue Mar 15, 2011 11:23 pm
by Daniel Garcia-Gil
Ruediger...

it's is a VERY INOFFENSIVE memory leak... this gdi object is created only one time to build 2007 menu effect... dont worry about that...

Re: Memory leak with MENU 2007

Posted: Thu Mar 17, 2011 10:21 pm
by IBTC
Hi Daniel,
Daniel Garcia-Gil wrote:this gdi object is created only one time to build 2007 menu effect... dont worry about that...
But I am worried about, because I made more tests with FWH 11.01. And everytime a POPUP MENU is called there is 1 unreleased gdi object more. So if my customers start my app, work some hours with it and call a POPUP MENU e.g. about 100 times, there are about 100 unreleased gdi objects. This is not acceptable.

Code: Select all

//----------------------------------------------------------------------------// 

FUNCTION MAIN()

   LOCAL oWnd

   SetResDebug()

   DEFINE WINDOW oWnd FROM 1, 1 TO 22, 75 ;
      TITLE "Test";
      MENU BuildMenu()

   ACTIVATE WINDOW oWnd;
         ON RIGHT CLICK ShortMainMenu(oWnd)

   FERASE("CHECKRES.TXT")
   CHECKRES()
   winExec("notepad .\checkres.txt")

return(0)

//----------------------------------------------------------------------------//

function ShortMainMenu(oWnd)

   local oMenu, aPos

   aPos := ScreenToClient( oWnd:hWnd, GetCursorPos() )

   MENU oMenu POPUP 2007

      MENUITEM "Item 1"

   ENDMENU

   activate popup oMenu of oWnd at aPos[1], aPos[2]

return oMenu

function BuildMenu()

   local oMenu

   MENU oMenu 2007

      MENUITEM "Item 1"

   ENDMENU

return oMenu

//----------------------------------------------------------------------------//
If I call the popup menu with right click e.g. 5 times, I get this:

Code: Select all

03/17/11 23:14:30: BMP,1568,TWINDOW:HANDLEEVENT(0)->_FWH(3408)->SHOWWINDOW(0)->TWINDOW:ACTIVATE(975)->MAIN(17)
    
03/17/11 23:14:30: BMP,2160,TWINDOW:HANDLEEVENT(0)->_FWH(3408)->TRACKPOPUP(0)->TMENU:ACTIVATE(470)->SHORTMAINMENU(39)->(b)MAIN(17)->TWINDOW:RBUTTONDOWN(1907)->TWINDOW:HANDLEEVENT(0)->_FWH(3408)->WINRUN(0)->TWINDOW:ACTIVATE(992)->MAIN(17)
    
03/17/11 23:14:30: BMP,2532,TWINDOW:HANDLEEVENT(0)->_FWH(3408)->TRACKPOPUP(0)->TMENU:ACTIVATE(470)->SHORTMAINMENU(39)->(b)MAIN(17)->TWINDOW:RBUTTONDOWN(1907)->TWINDOW:HANDLEEVENT(0)->_FWH(3408)->WINRUN(0)->TWINDOW:ACTIVATE(992)->MAIN(17)
    
03/17/11 23:14:30: BMP,2880,TWINDOW:HANDLEEVENT(0)->_FWH(3408)->TRACKPOPUP(0)->TMENU:ACTIVATE(470)->SHORTMAINMENU(39)->(b)MAIN(17)->TWINDOW:RBUTTONDOWN(1907)->TWINDOW:HANDLEEVENT(0)->_FWH(3408)->WINRUN(0)->TWINDOW:ACTIVATE(992)->MAIN(17)
    
03/17/11 23:14:30: BMP,3140,TWINDOW:HANDLEEVENT(0)->_FWH(3408)->TRACKPOPUP(0)->TMENU:ACTIVATE(470)->SHORTMAINMENU(39)->(b)MAIN(17)->TWINDOW:RBUTTONDOWN(1907)->TWINDOW:HANDLEEVENT(0)->_FWH(3408)->WINRUN(0)->TWINDOW:ACTIVATE(992)->MAIN(17)
    
03/17/11 23:14:30: ====================================================================================================

Re: Memory leak with MENU 2007

Posted: Fri Mar 18, 2011 12:07 am
by Daniel Garcia-Gil
Yes...

we will fix soon


thanks for feedback

Re: Memory leak with MENU 2007

Posted: Mon Mar 28, 2011 11:18 am
by Antonio Linares
Ruediger,

Do you get the same without using 2007 in the popup menu creation ? thanks

Re: Memory leak with MENU 2007

Posted: Mon Mar 28, 2011 11:40 am
by Antonio Linares
Yes, it is the 2007 clause...

searching...

Re: Memory leak with MENU 2007

Posted: Mon Mar 28, 2011 11:53 am
by Antonio Linares
* Fix: Clause 2007 was releasing a bitmap but not removing it from the FWH list. Now it is ok.
(still a pending one there). FWH 11.03