I can now reproduce my crash issue... it's mostly related brush freeing before getting a new brush for the same ID. AFAIK Hollywood should free the previous brush automatically and you haven't needed to use the
FreeBrush() command usually when re-using the ID, but that doesn't seem to happen with Polybios. If you don't free the previous brush manually, there seems to be memory leaking. This alone doesn't seem to make the crash here (on MorphOS), but if I also display the brush with custom dimensions, then it crashes sooner or later.
So, these are my observations now (I've used
this PDF when testing):
1) This code will leak memory until all is gone. The memoy isn't free'ed when you quit the program (at least under MorphOS). It also leaks under Windows with a quick test (not sure about freeing though, probably frees?).
Code: Select all
@REQUIRE "polybios"
EscapeQuit(True)
pdf.OpenDocument(1, "Apollo_datasheet.pdf")
PDF_DOCUMENT = pdf.GetObjectType()
numpages = GetAttribute(PDF_DOCUMENT, 1, #PDFATTRPAGES)
Repeat
For i=1 To numpages
pdf.GetBrush(1, i, 1)
DisplayBrush(1, 0, 0)
;FreeBrush(1) ; Enabling this would fix the problem
Next
Forever
2) Adding image scaling will cause the same example to crash after some rounds (randomish) under MorphOS, but with a quick try under Windows it didn't crash, just consumed memory increasingly.
Code: Select all
@REQUIRE "polybios"
EscapeQuit(True)
pdf.OpenDocument(1, "Apollo_datasheet.pdf")
PDF_DOCUMENT = pdf.GetObjectType()
numpages = GetAttribute(PDF_DOCUMENT, 1, #PDFATTRPAGES)
Repeat
For i=1 To numpages
pdf.GetBrush(1, i, 1)
DisplayBrush(1, 0, 0, {Width=GetAttribute(#DISPLAY,0,#ATTRWIDTH), Height=GetAttribute(#DISPLAY,0,#ATTRHEIGHT)}) ; <-- makes it unstable
;FreeBrush(1) ; Enabling this would fix the problem
Next
Forever
So, is this a user error or should Hollywood/Polybios handle this itself? I think I've only seen a mention to free the brushes before closing the document, but not before getting a new page...