NoLeak - include to help you find memory leaks (PB5.20)
Re: NoLeak - include to help you find memory leaks (1.4)
ClearStructure() is only needed if you call InitializeStructure() somewhen (After AllocateMemory() for example). Beside that, all is automatically managed by PB.
Re: NoLeak - include to help you find memory leaks (1.3)
Thanks. I did left an old param for catchimage() not present anymore. Hope it's ok now.sec wrote: I get macro error:
And yes, noleak catches only one class of macroscopic errors basically... (mismatched allocations/deallocations through allocatememory/freememory). It's a very limited tool.
It can help in some cases, but cannot do what you can do manually, and I feel trying to add more "intelligence" to it would cause more false reports than not.
For GDI leakages look at the GDIView tool mentioned in my first post (it can't tell you were they are in your code but it can help to verify their presence and the kind of objects leaking).
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
Re: NoLeak - include to help you find memory leaks (1.4)
Thank you much luis for sharing this program, and infratec for your addin part.
I like this NoLeak detector, as it helps me correct mistakes that lead to leak errors in my programs.
But I like infratec's approach for more location detail. But for what it's worth, I also added the line
'text' to the problem causing line number for a quick reference with out having to go to the line to
see what's wrong. It is in the following code. Just add to luis's source as infratec says on page 2.
I posted it here in case anyone else wants to use it too.
yrreti
I like this NoLeak detector, as it helps me correct mistakes that lead to leak errors in my programs.
But I like infratec's approach for more location detail. But for what it's worth, I also added the line
'text' to the problem causing line number for a quick reference with out having to go to the line to
see what's wrong. It is in the following code. Just add to luis's source as infratec says on page 2.
I posted it here in case anyone else wants to use it too.
Code: Select all
;{ DebugNoLeak()
Procedure DebugNoLeak()
Shared NoLeak_FONT(), NoLeak_ALLOC(), NoLeak_IMAGE()
Protected i,TheSource$,lp.i,TmpFile$,line_pos.i,thedat$
i = 0
If ListSize(NoLeak_FONT())
Debug ""
Debug "NoLeak Font:"
Debug ""
ForEach NoLeak_FONT()
i + 1
Debug "(" + Str(i) + ") " + "File: " + NoLeak_FONT()\Source$
line_pos=NoLeak_FONT()\iLine
TheSource$=NoLeak_FONT()\Source$
TmpFile$ = GetPathPart(TheSource$)+"tmp.txt"
While CopyFile(TheSource$, TmpFile$)=0:Wend
ReadFile(1,TmpFile$)
lp=0
While Eof(1) = 0
thedat$=ReadString(1)
lp=lp+1
If lp=line_pos
Debug "(" + Str(i) + ") " + "Line: " + Str(line_pos)+" "+thedat$
Break
EndIf
Wend
CloseFile(1)
DeleteFile(TmpFile$)
Debug "(" + Str(i) + ") " + "ID: " + Str(NoLeak_FONT()\iFontNum)
Debug "(" + Str(i) + ") " + "Name: " + NoLeak_FONT()\Filename$
Debug "(" + Str(i) + ") " + "Size: " + Str(NoLeak_FONT()\iYsize)
Debug ""
Next
Debug "----------------------------"
EndIf
If ListSize(NoLeak_ALLOC())
Debug ""
Debug "NoLeak Alloc:"
Debug ""
ForEach NoLeak_ALLOC()
i + 1
Debug "(" + Str(i) + ") " + "File: " + NoLeak_ALLOC()\Source$
line_pos=NoLeak_ALLOC()\iLine
TheSource$=NoLeak_ALLOC()\Source$
TmpFile$ = GetPathPart(TheSource$)+"tmp.txt"
While CopyFile(TheSource$, TmpFile$)=0:Wend
ReadFile(1,TmpFile$)
lp=0
While Eof(1) = 0
thedat$=ReadString(1)
lp=lp+1
If lp=line_pos
Debug "(" + Str(i) + ") " + "Line: " + Str(line_pos)+" "+thedat$
Break
EndIf
Wend
CloseFile(1)
DeleteFile(TmpFile$)
Debug "(" + Str(i) + ") " + "Address: " + Str(NoLeak_ALLOC()\iAddress)
Debug "(" + Str(i) + ") " + "Size: " + Str(NoLeak_ALLOC()\iBytes)
Debug ""
Next
Debug "----------------------------"
EndIf
If ListSize(NoLeak_IMAGE())
Debug ""
Debug "NoLeak Image:"
Debug ""
ForEach NoLeak_IMAGE()
i + 1
Debug "(" + Str(i) + ") " + "File: " + NoLeak_IMAGE()\Source$
line_pos=NoLeak_IMAGE()\iLine
TheSource$=NoLeak_IMAGE()\Source$
TmpFile$ = GetPathPart(TheSource$)+"tmp.txt"
While CopyFile(TheSource$, TmpFile$)=0:Wend
ReadFile(1,TmpFile$)
lp=0
While Eof(1) = 0
thedat$=ReadString(1)
lp=lp+1
If lp=line_pos
Debug "(" + Str(i) + ") " + "Line: " + Str(line_pos)+" "+thedat$
Break
EndIf
Wend
CloseFile(1)
DeleteFile(TmpFile$)
Debug "(" + Str(i) + ") " + "ID: " + Str(NoLeak_IMAGE()\iImageNum)
Debug "(" + Str(i) + ") " + "Width: " + Str(NoLeak_IMAGE()\iWidth)
Debug "(" + Str(i) + ") " + "Height: " + Str(NoLeak_IMAGE()\iHeight)
Debug "(" + Str(i) + ") " + "Depth: " + Str(NoLeak_IMAGE()\iDepth)
Debug ""
Next
Debug "----------------------------"
EndIf
If i > 0
Debug "NoLeak found " + Str(i) + " leaks!"
Else
Debug "NoLeak found no leaks!"
EndIf
EndProcedure
;}
CompilerElse
Macro DebugNoLeak()
EndMacro
Re: NoLeak - include to help you find memory leaks (PB5.20)
@luis:
If you change the lineto:
it works also on Mac OS X (and probably GNU/Linux).
If you change the line
Code: Select all
Macro CreateImage (iImageNum, iWidth, iHeight, iDepth = 24, iBackColor = #Black)
Code: Select all
Macro CreateImage (iImageNum, iWidth, iHeight, iDepth = 24, iBackColor = RGB(0,0,0))
Re: NoLeak - include to help you find memory leaks (PB5.20)
@Danilo
I changed it, thanks.
I changed it, thanks.
"Have you tried turning it off and on again ?"
A little PureBasic review
A little PureBasic review
Re: NoLeak - include to help you find memory leaks (PB5.20)
Thanks, nice memory-related addition to Purifier and really cool stuff, -1 way to be a fool [million remains] 

"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"