Patch to fix pbzx memory leaks

Used for discussing the various tools in the book as well as encouraging members to share tools

Patch to fix pbzx memory leaks

Postby ryandesign » Mon Feb 05, 2018 12:46 am

Thank you for writing the pbzx tool. Using the version from 20170731 posted in your OTA: Episode V : XZ strikes back post, I noticed that while decompressing the pbzx stream inside Xcode_9.2.xip, the pbzx program's memory usage kept growing up to 11GB. After applying this patch, memory usage stayed around 20-30MB.

Code: Select all
Fix memory leaks.
--- 02_decompress.c.orig   2017-07-31 11:26:22.000000000 -0500
+++ 02_decompress.c   2018-02-04 01:32:19.000000000 -0600
@@ -378,6 +378,7 @@
 
    decompressBytes(&strm, buf, size);
 
+   lzma_end(&strm);
 
 
 }
--- pbzx.c.orig   2017-07-31 11:25:52.000000000 -0500
+++ pbzx.c   2018-02-04 01:22:14.000000000 -0600
@@ -120,6 +120,7 @@
    warn = 0;
 
    }
+   free(buf);
     }
 
     return 0;
ryandesign
 
Posts: 5
Joined: Mon Feb 05, 2018 12:38 am

Re: Patch to fix pbzx memory leaks

Postby morpheus » Mon Feb 05, 2018 2:31 am

Thanks for the fix! I never really thought about freeing memory because pbzx and Ota execute for a very short time and exit - but every improvement helps !
morpheus
Site Admin
 
Posts: 734
Joined: Thu Apr 11, 2013 6:24 pm

Re: Patch to fix pbzx memory leaks

Postby ryandesign » Thu Mar 15, 2018 5:40 pm

I see that you released a new version of pbzx.c on March 10, 2018, but it does not contain this fix. Could you release a new version of pbzx.c and 02_decompress.c containing these fixes? The difference between using 30MB of memory and using 11GB of memory is pretty significant.

J says: Ooops. Forgot that. Added in sources.
ryandesign
 
Posts: 5
Joined: Mon Feb 05, 2018 12:38 am


Return to Tools

Who is online

Users browsing this forum: No registered users and 2 guests

cron