MessageEventArgs - Memory usage double with setData without purpose

Open
#472 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
55/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
csharp
Domain
networking

Research direction

Start in MessageEventArgs.cs around lines 104-109 and inspect the linked commit's setData implementation and RawData path. Confirm how _data is populated when RawData is accessed, then change the behavior so RawData does not call setData while preserving the intended Data behavior. Done means RawData no longer creates the duplicated data described in the issue.

Written by the indexing model from the issue text.

Description

By looking at this commit and the code of setData
https://github.com/sta/websocket-sharp/commit/0b07b08ad0822e1b8063737989336b36b2d19cc1 there is no purpose of calling setData in get RawData.
This will create/duplicate an unused memory with _data that probably will hold a huge frame.

We can also think that _data has no real purpose else that not calling a conversion for each get Data but in some case, holding memory is heavier than CPU conversion usage.
https://github.com/sta/websocket-sharp/blob/0b3a346b86351840cb2171630a37d8b8c94855ce/websocket-sharp/MessageEventArgs.cs#L104-L109

At least please, make RawData not calling setData to keep a choice to have a clean memory usage.

Dominant language
C#
Stars
6.1k
Forks
1.7k
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sta/websocket-sharp

All issues in sta/websocket-sharp

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.