jira.codehaus.org

  • Log In Access more options
    • Online Help
    • Keyboard Shortcuts
    • About JIRA
    • JIRA Credits
    • What?s New
  • Dashboards Access more options (Alt+d)
  • Projects Access more options (Alt+p)
  • Issues Access more options (Alt+i)
  • JRuby
  • JRUBY-3089

Digest::Base stores in memory all bytes passed to the digest, causing OutOfMemoryError

  • Log In
  • Views
    • XML
    • Word
    • Printable

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Critical Critical
  • Resolution: Fixed
  • Affects Version/s: JRuby 1.1.4
  • Fix Version/s: JRuby 1.2
  • Component/s: Extensions
  • Labels:
    None

Description

Digest::Base is currently implemented by appending to a StringBuffer.

This will cause a certain OutOfMemoryError if you try to digest a file which approaches half of your memory limit, which makes it unsuitable for the kind of task for which digests are commonly used (i.e. finding the digest of files for the sake of comparison.)

Instead of using an internal StringBuffer it should just update the MessageDigest directly.

Activity

Ascending order - Click to sort in descending order
  • All
  • Comments
  • Work Log
  • History
  • Activity
Hide
Permalink
Charles Oliver Nutter added a comment - 30/Oct/08 1:52 AM

Can you come up with a patch for this? It's probably not hard, but we're pretty slammed with 1.1.5 preparations right now.

Show
Charles Oliver Nutter added a comment - 30/Oct/08 1:52 AM Can you come up with a patch for this? It's probably not hard, but we're pretty slammed with 1.1.5 preparations right now.
Hide
Permalink
Trejkaz added a comment - 04/Nov/08 5:33 PM

Time seems a bit tight right now for me. If I get some free time in the next week or so I'll take a shot at it.

Assuming there are specs already, anyway, as that's the only way I'll know how it's really supposed to work.

Show
Trejkaz added a comment - 04/Nov/08 5:33 PM Time seems a bit tight right now for me. If I get some free time in the next week or so I'll take a shot at it. Assuming there are specs already, anyway, as that's the only way I'll know how it's really supposed to work.
Hide
Permalink
Charles Oliver Nutter added a comment - 12/Feb/09 3:06 AM

Fixed in r9110.

It turned out that all the MessageDigest objects from JDK are cloneable; so instead of storing all data in-memory and re-digesting every time, we can continue to update the same digest and clone it immediately before producing intermediate results. This lets us produce intermediate results without finishing off the digest.

Performance is likely improved as well, since it won't have to digest all the data anew every time a digest is requested. I also made a few minor perf cleanups to eliminate extra back-and-forth to Java Strings.

Show
Charles Oliver Nutter added a comment - 12/Feb/09 3:06 AM Fixed in r9110. It turned out that all the MessageDigest objects from JDK are cloneable; so instead of storing all data in-memory and re-digesting every time, we can continue to update the same digest and clone it immediately before producing intermediate results. This lets us produce intermediate results without finishing off the digest. Performance is likely improved as well, since it won't have to digest all the data anew every time a digest is requested. I also made a few minor perf cleanups to eliminate extra back-and-forth to Java Strings.

People

  • Assignee:
    Charles Oliver Nutter
    Reporter:
    Trejkaz
Vote (0)
Watch (0)

Dates

  • Created:
    28/Oct/08 6:34 PM
    Updated:
    21/Mar/09 1:14 PM
    Resolved:
    12/Feb/09 3:06 AM
  • Atlassian JIRA (v5.0.4#731-sha1:3aa7374)
  • Report a problem
  • Powered by a free Atlassian JIRA open source license for Codehaus. Try JIRA - bug tracking software for your team.