Skip Menu |

This queue is for tickets about the Filter-Crypto CPAN distribution.

Report information
The Basics
Id: 95021
Status: resolved
Priority: 0/
Queue: Filter-Crypto

People
Owner: Nobody in particular
Requestors: kgroeneveld [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: inefficient heap usage in Decrypt.xs
Date: Thu, 24 Apr 2014 17:50:09 -0400
To: bug-Filter-Crypto [...] rt.cpan.org
From: Kevin Groeneveld <kgroeneveld [...] gmail.com>
I have been trying to use Filter::Crypto with a few perl programs recently. In general everything is working great but I noticed that the memory usage of the perl process is often MUCH higher when using Filter::Crypto. For example, I have one script where the perl process would be almost 30M bigger. This is significant when running on an embedded system with limited memory. I tracked the issue down to the mortal SV buffers in FilterCrypto_FilterDecrypt. This function gets called for each line of source code that is being decrypted so a couple new SVs (totally 24k in my test case) get allocated for each line. While the buffers eventually are freed the way the heap grows and becomes fragmented the actual memory usage of the stack can remain quite large. Attached is a patch with one possible way of fixing the issue. The patch allocates one set of buffers and reuses them for each call to FilterCrypto_FilterDecrypt. I am not a perl or XS expert so this may not be a good way to fix it but the patch is working for me. Kevin

Message body is not shown because sender requested not to inline it.

Thanks for the patch. I've had another report of high memory usage recently so hopefully the issue that you've identified will resolve that one too. I'm currently working on a new release which I hope will be out fairly soon now, and will look to include your patch or something similar in it.
Thanks again for the patch. I've now applied something very similar in the GitHub repo: https://github.com/steve-m-hay/Filter-Crypto/commit/83333a4553cfa079a60ad99db1d3d65e3950eaee This will be in version 2.05, to be released shortly.