PXC_AddImageFromHBITMAP doesn't release memory

This Forum is for the use of Software Developers requiring help and assistance for Tracker Software's PDF-Tools SDK of Library DLL functions(only) - Please use the PDF-XChange Drivers API SDK Forum for assistance with all PDF Print Driver related topics or PDF-XChange Viewer SDK if appropriate.

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

ondrejb
User
Posts: 29
Joined: Thu Sep 04, 2008 2:06 pm

PXC_AddImageFromHBITMAP doesn't release memory

Post by ondrejb »

Hello,
I noticed that the PXC_AddImageFromHBITMAP consumes (and doesn't release) quite large amount of memory - see the attached project.
The memory consumption increases with image size: for the small image in the attached project it takes about 5MB, for A4/300dpi it consumes about 40MB.

When using the PXC_AddImageW instead of PXC_AddImageFromHBITMAP, the memory usage is OK.

Steps to reproduce behavior:
1. Run the attached application
2. Create PDF by clicking the Create PDF button
3. Each time the button is clicked, the memory usage of the application is increased for about 5 MB (check in the Task Manager)

My configuration:
* PDF-XChange PRO 4 SDK, build 4.0.0.152
* VB.NET 2008, ver. 9.0.30729.1 SP (with SP1)
* Win Vista Business SP1
You do not have the required permissions to view the files attached to this post.
User avatar
Lzcat - Tracker Supp
Site Admin
Posts: 677
Joined: Thu Jun 28, 2007 8:42 am

Re: PXC_AddImageFromHBITMAP doesn't release memory

Post by Lzcat - Tracker Supp »

PXC_AddImageFromHBITMAP does not free bitmap handle passed to it, so it must be released in your code. See Remarks section in Bitmap::GetHbitmap method help - http://msdn.microsoft.com/en-us/library/1dz311e4.aspx Also see attached corrected sample. By the way, your code is less effective than using PXC_AddImageW or PXC_AddImageFromImageXChangePage - because of about three times larger memory usage.
You do not have the required permissions to view the files attached to this post.
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.
ondrejb
User
Posts: 29
Joined: Thu Sep 04, 2008 2:06 pm

Re: PXC_AddImageFromHBITMAP doesn't release memory

Post by ondrejb »

Thank you!

Ad code efficiency - this was just a test/demo project; the real app inserts into PDF scanned images...