miyako / 4d-plugin-quick-look

Create QL preview, launch QL. 10.5+. 32/64 bits.
MIT License
2 stars 2 forks source link

Memory leak #1

Closed nilskoll closed 9 years ago

nilskoll commented 9 years ago

For each call to the plugin up to 5MB of memory is being allocated and never freed. Eventually the 4D app will crash. Tested with 4D 13.5.

Here is a sample code which will crash after about 1000 iterations. The source file is a graphic pdf (2MB size, 70x100cm poster created by InDesign).

If (False) Test_QuickLook End if

C_BOOLEAN($Done_bool) C_PICTURE(QuickLook_Large_picture) C_LONGINT($FilePreviewCount_l;$ImageSize_l;$MaxThumbnailCount_l)

C_TEXT($InputFilepath_text;$OutputFolder_text;$OutputPath_text) ARRAY TEXT($aFilePath_text;0)

$InputFilepath_text:=Select document("";".pdf";"Choose pdf document";0;$aFilePath_text) $Done_bool:=False $ImageSize_l:=500 $MaxThumbnailCount_l:=2000

If ($InputFilepath_text#"") $OutputFolder_text:=Select folder("Choose output folder") $FilePreviewCount_l:=1 $InputFilepath_text:=$aFilePath_text{1} If (Test path name($InputFilepath_text)=Is a document) Repeat $OutputPath_text:=$OutputFolder_text+"Thumbnail"+String($FilePreviewCount_l;"0000")+".jpg" QuickLook_Large_picture:=QL Get file thumbnail ($InputFilepath_text;$ImageSize_l;$ImageSize_l) WRITE PICTURE FILE($OutputPath_text;QuickLook_Large_picture) CLEAR VARIABLE(QuickLook_Large_picture)

$FilePreviewCount_l:=$FilePreviewCount_l+1 $Done_bool:=(Macintosh command down) | ($FilePreviewCount_l>$MaxThumbnailCount_l) | (Test path name($OutputPath_text)#Is a document) Until ($Done_bool) ALERT("Created "+String($FilePreviewCount_l)+" previews") SHOW ON DISK($OutputFolder_text) End if End if

miyako commented 9 years ago

https://github.com/miyako/4d-plugin-quick-look

could you try again with today’s version?

km

2015/04/24 4:30、nilskoll notifications@github.com のメール:

For each call to the plugin up to 5MB of memory is being allocated and never freed. Eventually the 4D app will crash. Tested with 4D 13.5.

宮古 啓介 セールス・エンジニア

株式会社フォーディー・ジャパン 〒150-0043 東京都渋谷区道玄坂1-10-2 渋谷THビル6F Tel: 03-6427-8441 Fax: 03-6427-8449

Keisuke.Miyako@4d.com www.4D.com/JP

nilskoll commented 9 years ago

Thanks for the new version Keisuke. I have tested it on my test database and it now created thousands of previews without any noticeable memory leak. I will test it on the production server tonight.

Best regards Nils Kollandsrud

nilskoll commented 9 years ago

The new version is working flawlessly! Thank you very much.

Nils