Menu

CSSLexer using too much memory.

sam
2014-03-02
2014-03-03
  • sam

    sam - 2014-03-02

    Thank you for this great job. I love it very much.

    I use it in my android project for parsing css file. every thing is good except OOM. I dived in codes, found this:
    CSSLexer.java

    static final short[][] DFA44_transition;
    
    static {
        int numStates = DFA44_transitionS.length;
        DFA44_transition = new short[numStates][];
        for (int i=0; i<numStates; i++) {
            DFA44_transition[i] = DFA.unpackEncodedString(DFA44_transitionS[i]);
        }
    }
    

    this static field cost too much memory: memory analyze report:
    The class "cz.vutbr.web.csskit.antlr.CSSLexer", loaded by "dalvik.system.PathClassLoader @ 0xa4ebd5e0", occupies 13,901,544 (73.78%) bytes. The memory is accumulated in one instance of "short[][]" loaded by "<system class="" loader="">".

    Could it improve?

     
  • Radek Burget

    Radek Burget - 2014-03-03

    Unfortunately, the CSSLexer.java file is generated automatically by ANTLR. It seems that people from Atlassian have already solved this problem:
    https://bitbucket.org/atlassian/jstyleparser/commits/5f73ba00532a4aae972817d31fa0c1bbda78324c#chg-src/main/patches/CSSLexer-dfa-large-arrays.patch

    They have a patch that is applied on the file once it is generated. They are using jstyleparser-1.13 but probably the some thing (with minor modification) may be applied to the currrent version as well. If you are able to propose a better solution, I will be glad to include it in the project.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.