IPXC_Document.WriteToFile Memory issue  SOLVED

PDF-XChange Editor SDK for Developers

Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan

Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.

When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
Post Reply
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

IPXC_Document.WriteToFile Memory issue

Post by jeffp »

I'm running into a very strange issue.

My Delphi application memory size grows every time I call the following:

var
FDoc: IPXC_Document;
...
FDoc.WriteToFile(PChar(AFileName), nil, 0)

And even after a call to

FDoc.Close(0);
FDoc := nil;

The memory still is not freed up.

It appears that there is something in the IPXC_Document.WriteToFile call that is bloating memory. Is there something I need to call to clear the bloat?

I've attached a simple Delphi project that will recreate this issue for you.

--Jeff

--Jeff
Attachments
EditorDemo.zip
(4.28 MiB) Downloaded 90 times
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

Hello Jeff,

We've tested this. This is a normal program workflow - the memory was released after some time - we've opened the files 20 times or so and the garbage collector cleaned some of the memory used.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

You mean "saved" the file 20 times or so?

I guess I'm not following you here. On my end repeated saves of the file bloats the memory as indicated in the task manager. And it doesn't get released when I close the document.

What do you mean by the garbage collector? Usually in Delphi the developer is responsible for freeing memery.

Did you actually run the Delphi project I sent with my last email? Maybe it works fine in C# but there is an issue in Delphi.

This is a very serious issue for me since when I process scanned images in my app, I do a lot of saving. As such, if some scans for 20 minutes or so the memory of my app grows very high and is a concern.

Again, can we focus on the sample project I sent. I want to ensure you are seeing with it what I am on my end.

--Jeff
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

Hello Jeff,

The memory began to release when it's bloated to the certain point (there is a memory limit for this). This behavior will be fixed in the next build 319.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

Can I get a dev release of the upcoming 319 build with the fix as soon as it is fixed?

Or is there something I can call in the meantime to force the memory cleanup after certain procedures that cause the memory bloat?

This is a big issue for my app so I'd like to test it asap.

What time frame are we talking here?

--Jeff
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

Ok. Just playing with my test project again and here's what I am seeing.

Again, just saving the file out is causing a memory bloat, but once the memory of the exe gets to about 450,000K as measured by task manager, it seems to purge itself and goes back to about 50,000K. But (and this is very strange) thereafter it seems to clean itself up after every save going forward.

The big issue for me is that I can't have my app growing from 25,000K to 400,000K for no apparent reason. You'd be surprised at the number of our users that monitor this stuff.

--Jeff
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

Hello Jeff,

The Dev. Build is being deployed right now - should be available in a couple of hours.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

Would you mind giving me the link again. I'll bookmark it this time.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

You can see it on top of the Edior SDK and Core API forums named Useful Resources.
https://www.pdf-xchange.com/forum3 ... 66&t=25943

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

Unfortunately, the new dev build does not appear to fix my memory bloat issue. I'm using the new PDFXEditCore.x86.dll marked as version 6.0.318.16083 on a Win7 machine. I've updated my sample project and posted it at the link below (let me know when you get it so I can remove it. Your attach button wasn't working);

http://www.lucion.com/files/MemoryTest.zip

Here's what you need to do to recreate the issue I'm seeing.

Just launch the Project1.exe file in the attached zip file and do the following:

Press the "Load Editor" button to load the editor. Note that after this the memory will be about 22,000K.

Now set the save test to 100 iterations and press the "Save Test" button. This will cause the program to open a simple PDF file and start saving it 100 times. Note that as the saves continue the memory grows. On my machine, after about 75 saves the memory is close to 450,000K. But shortly after that threshold, it drops back to about 57,000K and stays there for the rest of the saves.

Once the saves are done, the memory stays at around 57,000K.

What I'd expect to see is that the memory would climb a bit above the initial 22,000K during the save loop but it would be cleared after each save (no aggregate effect), and more importantly it would return to the initial 22,000K after the save test completes and the PDF doc is closed. This is what I observed with the older SDK DLLs before switching to the new Editor SDK.

Can you first see if you can reproduce what I described above with my sample project so we are on the same page.

Thanks,

Jeff
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: IPXC_Document.WriteToFile Memory issue

Post by Lzcat - Tracker Supp »

Hi Jeff.
and more importantly it would return to the initial 22,000K after the save test completes and the PDF doc is closed
Unfortunately this will never happen because during opening documents editor use some more memory and will not release all of it - some common data will stay in memory. However these resources will be loaded only once, so new stable memory usage should be not much higher (in your case - around 57,000K).
About dev build - fix is not present there, this is why you see old behavior with memory growth.
HTH.
Victor
Tracker Software
Project manager

Please archive any files posted to a ZIP, 7z or RAR file or they will be removed and not posted.
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

When will this fix be in the dev build for me to test out?

I'm fine with the small increase in memory when the file opens. The bigger issue was the memory growth upon doing multiple saves, and it sounds like you are addressing this one.

--Jeff
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

Hello Jeff,

The Dev Build will be prepared by Monday and it will contain this fix.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

Great. Thanks so much.
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue

Post by jeffp »

Did the dev build with this fix get posted?
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

The build is being deployed right now - should be available in a couple of hours.

Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
jeffp
User
Posts: 914
Joined: Wed Sep 30, 2009 6:53 pm

Re: IPXC_Document.WriteToFile Memory issue  SOLVED

Post by jeffp »

New dev build seems to have fixed this memory growth issue.

Much thanks.

--Jeff
Sasha - Tracker Dev Team
User
Posts: 5522
Joined: Fri Nov 21, 2014 8:27 am
Contact:

Re: IPXC_Document.WriteToFile Memory issue

Post by Sasha - Tracker Dev Team »

:)
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
Post Reply