The MASM Forum Archive 2004 to 2012

Project Support Forums => MASM32 => Topic started by: Farabi on August 25, 2008, 01:30:41 AM

Title: Masm lib problem
Post by: Farabi on August 25, 2008, 01:30:41 AM
Take a look at Window Task Manager when you use circle or line function, the memory usage is keep increasing as you call the function(about 20 k each call). Is it normal?
Title: Re: Masm lib problem
Post by: hutch-- on August 25, 2008, 02:45:47 AM
Which LIB function ?
Title: Re: Masm lib problem
Post by: ChrisLeslie on August 25, 2008, 05:37:38 AM
I remember running into this problem with "line.asm" in m32lib. I believe I invoked an extra delete object for "HPenOld" and re-assembled the module. Then it stopped chewing up memory after many calls to the line primitive. - Chris
Title: Re: Masm lib problem
Post by: hutch-- on August 25, 2008, 06:42:30 AM
Thanks Chris,

The "line" algo was missing a ReleaseDC() call at the exit of the proc. Got the hickups REAL BAD after a few hundred million calls.  :bg File was dated 1999 and no-one ever noticed it before. This is the fixed and modernised algo and the test piece is attached.


; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

linex proc hndl:DWORD,colr:DWORD,x1:DWORD,y1:DWORD,x2:DWORD,y2:DWORD

    LOCAL hDC     :DWORD
    LOCAL hPen    :DWORD
    LOCAL hPenOld :DWORD

    mov hDC, rv(GetDC,hndl)
    mov hPen, rv(CreatePen,0,1,colr)
    mov hPenOld, rv(SelectObject,hDC,hPen)

    invoke MoveToEx,hDC,x1,y1,NULL
    invoke LineTo,hDC,x2,y2

    invoke SelectObject,hDC,hPenOld
    invoke DeleteObject,hPen
    invoke ReleaseDC,hndl,hDC

    ret

linex endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

[attachment deleted by admin]
Title: Re: Masm lib problem
Post by: jj2007 on August 25, 2008, 07:47:49 AM
Quote from: hutch-- on August 25, 2008, 06:42:30 AM
Thanks Chris,

The "line" algo was missing a ReleaseDC() call at the exit of the proc. Got the hickups REAL BAD after a few hundred million calls.  :bg

New type??

hickups  REAL BAD 500000000