Skip to content

Getting memory out of exception issue while deserializing in Read method of Host.cs file #13

Open

Description

@aggyasinghal

The buffer char array if pretty large and hence while converting it to string in the Jsonconverter parameter getting an exception out of memory.

Activity

  1. acandylevey commented on May 6, 2021

    @acandylevey
    Owner

    What is the message you are trying to send across?

  2. aggyasinghal commented on May 6, 2021

    @aggyasinghal
    Author

    Any random string. For eg: a name

  3. aggyasinghal commented on May 6, 2021

    @aggyasinghal
    Author

    Can you give more light on this issue on how should I approach the method or what should be the steps to send the message?

  4. acandylevey commented on May 6, 2021

    @acandylevey
    Owner

    I will need some further information here, how are you are serialising the json object from the browser?

  5. aggyasinghal commented on May 6, 2021

    @aggyasinghal
    Author

    Sure.
    I'll explain the scenario which i want to work on.

    I want to send a message to the chrome extension using the c# host application which you have mentioned and based on that message my extension will work and return me the result.
    I want to know how can i make this work?
    Can you pleas explain me the process with an example if possible?

  6. acandylevey commented on May 6, 2021

    @acandylevey
    Owner

    I've raised an issue to #14 which I think once done will provide an end to end documentation on how it should all fit together.
    I'm hoping to get some time to work on it before the end of the month

  7. aggyasinghal commented on May 6, 2021

    @aggyasinghal
    Author

    For now, can you tell the input for this method?

    private static JObject Read()
    {
    //Log.LogMessage("Waiting for Data");

            Stream stdin = Console.OpenStandardInput();
    
            byte[] lengthBytes = new byte[4];
            stdin.Read(lengthBytes, 0, 4);
    
            char[] buffer = new char[BitConverter.ToInt32(lengthBytes, 0)];
    
            using (StreamReader reader = new StreamReader(stdin))
                if (reader.Peek() >= 0)
                    reader.Read(buffer, 0, buffer.Length);
            string val = new string(buffer);
    
            return JsonConvert.DeserializeObject<JObject>(val);
        }
    
  8. aggyasinghal commented on May 6, 2021

    @aggyasinghal
    Author

    What value should I put in when the console opens?

  9. aggyasinghal commented on May 6, 2021

    @aggyasinghal
    Author

    It was kind of urgent. If u can put up the document in issue #14 ASAP then it would be a great help.
    Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions