Memory leak in PrintToPDFFileMBS?

I’m printing with PrintToPDFFileMBS followed by using CGPDFDocumentMBS to add page numbers and a header. There is one user for whom this is crashing hard:

Thread 3 Crashed:
0 0x948c910e x_malloc + 28
1 0x947c8180 CGDataProviderCreateWithFilename + 213
2 0x9498a840 CGDataProviderCreateWithURL + 146
3 0x946c205b CGPDFDocumentCreateWithURL + 20
4 MBS_MacCG_CGPDF_Plugin_19503.dylib 0x09128189 OpenPDFDocument(REALfolderItemStruct*) + 41
5 com.mothsoftware.mailarchiverx 0x006ab238 folderitemCGPDFExtensionMBS.$OpenAsCGPDFDocumentMBS%o%o + 75
6 com.mothsoftware.mailarchiverx 0x01856179 WriteMessageToPDF.GetPDFAuthor%s%oo + 418
7 com.mothsoftware.mailarchiverx 0x01856e66 WriteMessageToPDF.GetListOfFiles%%oo + 1359
8 com.mothsoftware.mailarchiverx 0x01856c76 WriteMessageToPDF.GetListOfFiles%%oo + 863
9 com.mothsoftware.mailarchiverx 0x01856c76 WriteMessageToPDF.GetListOfFiles%%oo + 863
10 com.mothsoftware.mailarchiverx 0x01856c76 WriteMessageToPDF.GetListOfFiles%%oo + 863
11 com.mothsoftware.mailarchiverx 0x01854b8a WriteMessageToPDF.Constructor%%osobbi4ssb + 2201
12 com.mothsoftware.mailarchiverx 0x00e69f46 WriteMessageToDatabase.Constructor%%osoosb + 3501
13 com.mothsoftware.mailarchiverx 0x00f46b09 MailParser.parse%i4%o + 7740
14 com.mothsoftware.mailarchiverx 0x00f059f5 ArchiveThread.Archive%%o + 11067
15 com.mothsoftware.mailarchiverx 0x00f003fd ArchiveThread.Event_Run%%o + 79
16 com.xojo.XojoFramework 0x0257c34d 0x23bf000 + 1823565
17 com.xojo.XojoFramework 0x02454246 0x23bf000 + 610886
18 libsystem_pthread.dylib 0xa18d2047 _pthread_body + 184
19 libsystem_pthread.dylib 0xa18d1f8f _pthread_start + 243
20 libsystem_pthread.dylib 0xa18d184a thread_start + 34

This looks like the “usual” problem with memory.

When trying to write a lot of pdf files I can see a small memory leak. Not really much but for a hundreds or more files it adds up. Of, course I’m doing the auto release thing. When I take out the handling of the files with CGPDFDocumentMBS the memory leak remains so it can only come from PrintToPDFFileMBS.

@Christian: can you have a look if this is the case?

Xojo 2017r1, 32bit. Plugins from 27.11.2017.

Below is a screenshot from Instruments. Unfortunately, I’m more familiar with the Profiler part of Instruments.

You have a little test project?

e.g. where you press a button, something happens and memory goes up 10 MB on each click.

No test project so far and it’s way less than 10 MB for each file - at least for me. The user is seeing a larger memory leak.

I’ll try to make a test project in the next days.

Well, doesn’t need to be 10 MB, but I usually make test projects, so they leak a lot to make it easier to find.

SO if you can do something in a loop which increases memory a lot, I can easier debug it.

I found a leak of NSPrintInfo object. Fixed for next prerelease.
But that’s usually a small object and should not be a problem.