Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

larger values of crc_len can cause a MemoryError #90

Closed
robberwick opened this issue Apr 4, 2024 · 0 comments · Fixed by #101
Closed

larger values of crc_len can cause a MemoryError #90

robberwick opened this issue Apr 4, 2024 · 0 comments · Fixed by #101

Comments

@robberwick
Copy link
Contributor

robberwick commented Apr 4, 2024

In CRC.__init__(), the crc_len parameter is used to determine the length of the cs_table property, which is set as 2 ** crc_len. The entire list is then allocated in memory with the line

self.cs_table = [' '] * self.table_len

As the whole list needs to be in memory, this causes issue for even moderately large values of crc_len. On my machine (32GB ram), attempting to instantiate a crc instance with a crc_len of 32 hangs for a number of seconds before raising a MemoryError.

To resolve this, the pre-calculation of that cs_table could be deferred and performed lazily for each desired value, with that value being cached to prevent re-calculation. I would suggest not undertaking this work until #89 has been addressed, so that the potential for regressions can be reduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant