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

Crash when sending very large message with debug on #123

Closed
Steelight opened this issue Oct 9, 2012 · 8 comments
Closed

Crash when sending very large message with debug on #123

Steelight opened this issue Oct 9, 2012 · 8 comments

Comments

@Steelight
Copy link

When using debug prints, sending long messages crashes. I made a change to FramedataImpl1.toString() to fix this:

    @Override
    public String toString() {
        String payload = null;
        if (unmaskedpayload.array().length < 200)
        {
            payload = Arrays.toString( Charsetfunctions.utf8Bytes( new String( unmaskedpayload.array() ) ) );
        }
        else
        {
            byte[] subArray = Arrays.copyOfRange(unmaskedpayload.array(), 0, 200);
            payload = Arrays.toString( Charsetfunctions.utf8Bytes( new String( subArray ) ) );
        }
        return "Framedata{ optcode:" + getOpcode() + ", fin:" + isFin() + ", payloadlength:" + unmaskedpayload.limit() + ", payload:" + payload + "}";
    }

200 should be replaced with a proper value/constant, of course.

@Davidiusdadi
Copy link
Collaborator

Interesting, does your VM crash or do you get some sort of Error/Exception?

@Steelight
Copy link
Author

Out of memory exception, if I remember correctly.

@Davidiusdadi
Copy link
Collaborator

You should use the VM Xmx option to prevent this error.
The problem is not the toString method but the fact that your frames barely fit into memory.

You probably already know about Xmx but here is a link to that topic:

http://www.jafaloo.com/2011/10/30/java-xmx-memory-settings/

@Steelight
Copy link
Author

Did I mention I'm running on Android? I'm not sure if there's a way to do this on Android. According to this:
http://tordtech.blogspot.co.il/2009/09/memory-limit-on-android.html
it will require changing the Android source code.

@Davidiusdadi
Copy link
Collaborator

An other way is not to use so much memory... :trollface:

One think i wanted to do anyway is to allow to receive fragemented frames properly. Currently fragmented frames will be stored until all fragments of a frame are received and then delivered as one big frame. But receiving frames directly via an onFragment method would allow you to shrink the framebuffers size.

Would that help?

@Steelight
Copy link
Author

Well, actually, I'm sending these ginormous packages. They are sent and received (on the remote side) properly, and the only problem is with the debug prints.

@Davidiusdadi
Copy link
Collaborator

I'd suggest that you disable the debug prints...

@Steelight
Copy link
Author

Look, the problem is solved as far as I am concerned. If you want the fix, cool, if you don't, I'll just add it manually to future versions. I just wanted to share.

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

No branches or pull requests

2 participants