Last FWH version. Memory leak.

Re: Last FWH version. Memory leak.

Postby lucasdebeltran » Thu Feb 14, 2013 4:25 pm

Yes, in my opinion it is connected with Transbmp function.

Or maybe there is a leak in Fivewin´s internals, I don´t know.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: Last FWH version. Memory leak.

Postby Antonio Linares » Thu Feb 14, 2013 6:20 pm

Lucas,

If you have a real proof of that, then I appreciate if you show it.

If not, then I appreciate if you think it twice before saying it, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41373
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Last FWH version. Memory leak.

Postby Randal » Thu Feb 14, 2013 7:13 pm

Marco & Maurizio:

Can either of you verify if you were able to measure the problem using checkres or in some other way?

Or is all we know is that toolbar icons disappear after some period of time?

Can either of you offer any other insight or feedback?

I just upgraded to FWH 1212 and then 1301 and I'm afraid to start distributing our new version.

Randal Ferguson
Randal
 
Posts: 260
Joined: Mon Oct 24, 2005 8:04 pm

Re: Last FWH version. Memory leak.

Postby lucasdebeltran » Thu Feb 14, 2013 7:51 pm

Antonio,

Sory, the comment was not in a negative way. I do apologize for any inconvenience and thank you for your cooperation.

Yes, I did test with this function:

Code: Select all  Expand view

#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

static void TransBmp( HBITMAP hBitmap, int iXsize, int iYsize,
               COLORREF rgbTransparent, HDC hDC,
               int iXOffset, int iYOffset, int iWidth, int iHeight )
{
  HDC mDC, nDC;
  HBITMAP hMask, hBmOld1, hBmOld2;
  LPBYTE lpBits;

  mDC = CreateCompatibleDC( hDC );


  if( mDC )
  {
    hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );

    lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
    if( lpBits )
    {
      hMask = CreateBitmap( iXsize, iYsize, 1, 1, lpBits );
      if( hMask )
      {
        nDC = CreateCompatibleDC( hDC );
        if( nDC )
        {
          hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
          SetBkColor( mDC, rgbTransparent );

          BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );

          SetStretchBltMode( hDC, COLORONCOLOR );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      nDC, 0, 0, iXsize, iYsize,
                      SRCAND );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          SelectObject( nDC, hBmOld2 );
          DeleteDC( nDC );
        }
        else
           MessageBox( 0, "(1) Can't create compatible DC!", "Error", 0 );

        DeleteObject( hMask );
      }
      else
        MessageBox( 0, "(2) Can't create bitmap!", "Error", 0 );

      hb_xfree( lpBits );
    }
    else
            MessageBox( 0, "(3) Can't allocate memory!", "Error", 0 );

SelectObject( mDC, hBmOld1 );
    DeleteDC( mDC );
  }
  else
     MessageBox( 0, "(4) Can't create DC!", "Error", 0 );
}

HB_FUNC( TRANSBMP )
{
   TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
             ( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
             hb_parnl( 9 ) );
}

#pragma ENDDUMP
 



And when the bitmap disappear I receive Error (2) Can't create bitmap!.


Hope it helps to trace the problem.


Thanks again for your attention.
Muchas gracias. Many thanks.

Un saludo, Best regards,

Harbour 3.2.0dev, Borland C++ 5.82 y FWH 13.06 [producción]

Implementando MSVC 2010, FWH64 y ADO.

Abandonando uso xHarbour y SQLRDD.
User avatar
lucasdebeltran
 
Posts: 1303
Joined: Tue Jul 21, 2009 8:12 am

Re: Last FWH version. Memory leak.

Postby Antonio Linares » Thu Feb 14, 2013 11:39 pm

Lucas,

Esa información si es realmente util, gracias! :-)

hMask = CreateBitmap( iXsize, iYsize, 1, 1, lpBits );

lpBits existe y es correcto, ó no hubiese avanzado hasta ahí. Se me ocurre que los valores de iXsize ó iYsize sean erróneos (negativos) y de ahi que falle CreateBitmap()

Este error puedes reproducirlo ? Es siempre el mismo ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41373
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Last FWH version. Memory leak.

Postby Antonio Linares » Thu Feb 14, 2013 11:43 pm

Lucas,

Podemos interrogar por el error tan pronto como se produzca, el código a incluir es este:

Code: Select all  Expand view
  LPVOID lpMsgBuf;

   FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                  NULL,
                  GetLastError(),
                  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
                  ( LPTSTR ) &lpMsgBuf,
                  0,
                  NULL );
    MessageBox( 0, lpMsgBuf, "error", 0 );
   LocalFree( lpMsgBuf );
 


el código quedaría así:
Code: Select all  Expand view
#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

static void TransBmp( HBITMAP hBitmap, int iXsize, int iYsize,
               COLORREF rgbTransparent, HDC hDC,
               int iXOffset, int iYOffset, int iWidth, int iHeight )
{
  HDC mDC, nDC;
  HBITMAP hMask, hBmOld1, hBmOld2;
  LPBYTE lpBits;

  mDC = CreateCompatibleDC( hDC );


  if( mDC )
  {
    hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );

    lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
    if( lpBits )
    {
      hMask = CreateBitmap( iXsize, iYsize, 1, 1, lpBits );
      if( hMask )
      {
        nDC = CreateCompatibleDC( hDC );
        if( nDC )
        {
          hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
          SetBkColor( mDC, rgbTransparent );

          BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );

          SetStretchBltMode( hDC, COLORONCOLOR );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      nDC, 0, 0, iXsize, iYsize,
                      SRCAND );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          SelectObject( nDC, hBmOld2 );
          DeleteDC( nDC );
        }
        else
           MessageBox( 0, "(1) Can't create compatible DC!", "Error", 0 );

        DeleteObject( hMask );
      }
      else
      {
         LPVOID lpMsgBuf;

         FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                  NULL,
                  GetLastError(),
                  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
                  ( LPTSTR ) &lpMsgBuf,
                  0,
                  NULL );
        MessageBox( 0, lpMsgBuf, "(2) Can't create bitmap!", 0 );
        LocalFree( lpMsgBuf );
      }
      hb_xfree( lpBits );
    }
    else
            MessageBox( 0, "(3) Can't allocate memory!", "Error", 0 );

SelectObject( mDC, hBmOld1 );
    DeleteDC( mDC );
  }
  else
     MessageBox( 0, "(4) Can't create DC!", "Error", 0 );
}

HB_FUNC( TRANSBMP )
{
   TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
             ( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
             hb_parnl( 9 ) );
}

#pragma ENDDUMP
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41373
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Last FWH version. Memory leak.

Postby Bayron » Fri Feb 15, 2013 12:28 am

Colocando la función anterior, ahora al perder la imagen, obtengo este mensaje:

Image
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Last FWH version. Memory leak.

Postby Antonio Linares » Fri Feb 15, 2013 6:08 am

Bayron,

Por favor, prueba a cambiar esta línea asi:

static void TransBmp( HBITMAP hBitmap, unsigned int iXsize, unsigned int iYsize,
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41373
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Last FWH version. Memory leak.

Postby Antonio Linares » Fri Feb 15, 2013 6:15 am

Otro cambio, distinto al anterior, que puede solucionar el problema:

hMask = CreateBitmap( iXsize, iYsize, 1, 1, NULL ); // lpBits );

Creo que esto solucionará el problema definitivamente :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41373
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Last FWH version. Memory leak.

Postby shri_fwh » Fri Feb 15, 2013 6:34 am

Hi Antonio,

Would like to request to you to put the comment in english as well, as your comments are very improtant to us.

Thanks
Shridhar
Thanks
Shridhar
FWH 19.12, BCC 7 32 bit, MariaDB
shri_fwh
 
Posts: 301
Joined: Mon Dec 07, 2009 2:49 pm

Re: Last FWH version. Memory leak.

Postby Bayron » Fri Feb 15, 2013 11:35 am

I have not been loosing bitmaps in the last couple of hours... so it seems to be working...

Code: Select all  Expand view
#pragma BEGINDUMP

#include <windows.h>
#include <hbapi.h>

static void TransBmp( HBITMAP hBitmap, unsigned int iXsize, unsigned int iYsize,
               COLORREF rgbTransparent, HDC hDC,
               int iXOffset, int iYOffset, int iWidth, int iHeight )
{
  HDC mDC, nDC;
  HBITMAP hMask, hBmOld1, hBmOld2;
  LPBYTE lpBits;

  mDC = CreateCompatibleDC( hDC );


  if( mDC )
  {
    hBmOld1 = ( HBITMAP ) SelectObject( mDC, hBitmap );

    lpBits = ( LPBYTE ) hb_xgrab( iXsize * iYsize * 2 );
    if( lpBits )
    {
      hMask = CreateBitmap( iXsize, iYsize, 1, 1, NULL ); // lpBits );
      if( hMask )
      {
        nDC = CreateCompatibleDC( hDC );
        if( nDC )
        {
          hBmOld2 = ( HBITMAP ) SelectObject( nDC, hMask );
          SetBkColor( mDC, rgbTransparent );

          BitBlt( nDC, 0, 0, iXsize, iYsize, mDC, 0, 0, SRCCOPY );

          SetStretchBltMode( hDC, COLORONCOLOR );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      nDC, 0, 0, iXsize, iYsize,
                      SRCAND );

          StretchBlt( hDC, iXOffset, iYOffset, iWidth, iHeight,
                      mDC, 0, 0, iXsize, iYsize,
                      SRCINVERT );

          SelectObject( nDC, hBmOld2 );
          DeleteDC( nDC );
        }
        else
           MessageBox( 0, "(1) Can't create compatible DC!", "Error", 0 );

        DeleteObject( hMask );
      }
      else
      {
         LPVOID lpMsgBuf;

         FormatMessage( FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
                  NULL,
                  GetLastError(),
                  MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
                  ( LPTSTR ) &lpMsgBuf,
                  0,
                  NULL );
        MessageBox( 0, lpMsgBuf, "(2) Can't create bitmap!", 0 );
        LocalFree( lpMsgBuf );
      }
      hb_xfree( lpBits );
    }
    else
            MessageBox( 0, "(3) Can't allocate memory!", "Error", 0 );

SelectObject( mDC, hBmOld1 );
    DeleteDC( mDC );
  }
  else
     MessageBox( 0, "(4) Can't create DC!", "Error", 0 );
}

HB_FUNC( TRANSBMP )
{
   TransBmp( ( HBITMAP ) hb_parnl( 1 ), hb_parnl( 2 ), hb_parnl( 3 ), hb_parnl( 4 ),
             ( HDC ) hb_parnl( 5 ), hb_parnl( 6 ), hb_parnl( 7 ), hb_parnl( 8 ),
             hb_parnl( 9 ) );
}

#pragma ENDDUMP
 
=====>

Bayron Landaverry
(215)2226600 Philadelphia,PA, USA
+(502)46727275 Guatemala
MayaBuilders@gMail.com

FWH12.04||Harbour 3.2.0 (18754)||BCC6.5||UEstudio 10.10||
Windows 7 Ultimate

FiveWin, One line of code and it's done...
User avatar
Bayron
 
Posts: 815
Joined: Thu Dec 24, 2009 12:46 am
Location: Philadelphia, PA

Re: Last FWH version. Memory leak.

Postby Antonio Linares » Fri Feb 15, 2013 11:48 am

Bayron,

Many thanks for your tests :-)

Shridhar,

It seems as we finally found the bug and solved it :-)

"The mistery of the vanishing bitmaps" is over
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41373
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Last FWH version. Memory leak.

Postby IBTC » Fri Feb 15, 2013 12:55 pm

Antonio Linares wrote:It seems as we finally found the bug and solved it :-)


Great! Thanks to all. :-)
Best Regards,
Ruediger Alich

---
HMG 3.1.3 | FTDN/FWH 13.12 | Harbour 3.2 | BCC/MinGW | Windows XP/Vista/7/8/10 (32/64-Bit), Wine (Linux/Mac) - started 1999 with FW, 1989 with Clipper
User avatar
IBTC
 
Posts: 103
Joined: Sat Oct 18, 2008 8:13 pm
Location: Stuttgart, Germany

Re: Last FWH version. Memory leak.

Postby Maurizio » Fri Feb 15, 2013 1:52 pm

Antonio,

Thank ,
I really hope that the problem it solved .

Regards Maurizio
User avatar
Maurizio
 
Posts: 798
Joined: Mon Oct 10, 2005 1:29 pm

Re: Last FWH version. Memory leak.

Postby Antonio Linares » Fri Feb 15, 2013 2:58 pm

Maurizio,

It was in front of our eyes all this time but we didn't see it :-)

We were supplying a wrong buffer filled with garbage. Sometimes Windows was able to manage it, but sometimes, the memory garbish (as it was an unitialized memory block) had wrong data for WIndows. And the fact is that such buffer was not needed at all :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41373
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 41 guests