Prev: Lowlevel printing (ESC-codes sending to printer) with Vista ***THIS WORKS***
Next: Create email and attach PDF from ReportPro3?
From: John Martens on 15 Nov 2009 13:01 I'm having a problem with a memory leak in my app. When building a window I always check for Memory(MEMORY_REGISTERAXIT) when I open the window and check it when the window is closed (and the GC is called). If the memory is the same I think that there is no memory problem. Now I see in the windows task-manager that memory use is growing in time. I want to check where the problem arises. What VO value can I use to see if I'm having a memoty leak ? John
From: dlzc on 15 Nov 2009 20:43 Dear John Martens: On Nov 15, 11:01 am, John Martens <adsl672...(a)tiscali.nl> wrote: > I'm having a problem with a memory leak in my app. This does not directly answer your question, however: 1) see if you can identify which type of operation is doing it. 2) see if you can move that operation to a separate exe, and have Windoze see if it can reclaim the memory successfully upon termination of that code. Yes, it may be something you can control through different coding, some expected-but-not-enforced technique of function call (or clean up). But... David A. Smith
From: John Martens on 16 Nov 2009 11:40
David, The problem is in the method below. Each time it is called the memory usage in windows task explorer rises. The problem is not in the DibSave functions. Any idea what is causing the memory leak ? Should all PTR's be FREE's or deleted at the end of the method ? Cheers, John METHOD WindowToPicture(cFileNm,iRandDiktePar) CLASS DataWindow // Logic * * sending window content to a PNG file * from Google * Printing a window * Van: Steph * Datum: Fri, Mar 24 2006 5:54 pm LOCAL lMethResult := FALSE AS LOGIC LOCAL iRandDikte := 0 AS INT LOCAL pBMI AS _WINBITMAPINFO LOCAL nWidth AS INT LOCAL nHeight AS INT LOCAL hDIB AS PTR LOCAL pszFile AS PSZ LOCAL hDC AS PTR LOCAL hBitmap AS PTR LOCAL hOldBitmap AS PTR LOCAL hMemDC AS PTR * * kijken naar randdikte IF IsNumeric(iRandDiktePar) iRandDikte := iRandDiktePar ENDIF InitializeCAPaint() hMemDC:=CreateCompatibleDC(NULL) hDC :=GetDC(SELF:oSurface:Handle()) // GetDC(SELF:Handle(2)) hBitmap :=CreateCompatibleBitmap(hDC,SELF:Size:Width,SELF:Size:Height) hOldBitmap:=SelectObject(hMemDC,hBitmap) ReleaseDC(SELF:oSurface:Handle(),hDC) SendMessage(SELF:Handle(),WM_PRINT,DWORD(_CAST,hMemDC),PRF_CHILDREN+PRF_CLIENT+PRF_ERASEBKGND+PRF_OWNED) SelectObject(hMemDC,hOldBitmap) IF '.' $ cFileNm pszFile := StringAlloc(cFileNm) ELSE pszFile := StringAlloc(cFileNm+'.PNG') ENDIF hDIB := DIBCreateFromHBitmap(hBitmap) IF hDIB != NULL_PTR pBMI:=DIBGetInfo(hDIB) nWidth :=pBMI.bmiHeader.biWidth - iRandDikte nHeight:=pBMI.bmiHeader.biHeight - iRandDikte IF pBMI.bmiHeader.biBitCount!=32 hDIB:=DIBCreateCopy(hDIB,32) ENDIF DIBCrop(hDIB,iRandDikte,nWidth,iRandDikte,nHeight) DO CASE CASE '.BMP' $ upper(Psz2String(pszFile)) .OR. '.DIB' $ upper(Psz2String(pszFile)) DIBSaveAs(hDIB,pszFile) CASE '.JPG' $ upper(Psz2String(pszFile)) .OR. '.JPEG' $ upper(Psz2String(pszFile)) DIBSaveAsJPEG(hDIB,pszFile) OTHERWISE DIBSaveAsPNG(hDIB,pszFile) ENDCASE lMethResult := File(Psz2String(pszFile)) ENDIF MemFree(pszFile) DeleteObject(hBitmap) DeleteDC(hMemDC) FreeCAPaint() RETURN lMethResult dlzc schreef: > Dear John Martens: > > On Nov 15, 11:01 am, John Martens <adsl672...(a)tiscali.nl> wrote: >> I'm having a problem with a memory leak in my app. > > This does not directly answer your question, however: > 1) see if you can identify which type of operation is doing it. > 2) see if you can move that operation to a separate exe, and have > Windoze see if it can reclaim the memory successfully upon termination > of that code. > > Yes, it may be something you can control through different coding, > some expected-but-not-enforced technique of function call (or clean > up). But... > > David A. Smith |