FreeDSx / ASN1

An ASN.1 Library for PHP.
MIT License
10 stars 3 forks source link

Encoder Memory Issues #5

Closed ChadSikorra closed 5 years ago

ChadSikorra commented 5 years ago

When decoding a large ASN.1 structure the encoder seems to use an unusually large amount of memory which can completely exhaust the default memory limit in PHP. This is likely due to the use of the encoders substr usage while chunking up the binary data and not releasing it in certain spots. Need to take a closer look on how to improve this.

ChadSikorra commented 5 years ago

This has been resolved with various optimizations. I now use position based decoding instead of multiple substr calls, and null out the data after it is not needed. It is now much faster and more memory efficient. I compared it with the decoding done by the PHP LDAP extension (via OpenLDAP) and they are now comparable and trigger memory exhaustion errors around the same time (unavoidable with memory limits and huge data sets).