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

GZipFile: Remove on-stack allocation #5495

Open
madmaxoft opened this issue May 10, 2023 · 6 comments
Open

GZipFile: Remove on-stack allocation #5495

madmaxoft opened this issue May 10, 2023 · 6 comments

Comments

@madmaxoft
Copy link
Member

Currently GZipFile::ReadRestOfFile() allocates the result on stack, resulting in 128 KiB stack usage. VS has a soft-complaint about it.

We should change the Compression::Result type to always hold data on the heap. There's no benefit in keeping it stack-based.

@MrSach
Copy link

MrSach commented May 17, 2023

Hello, I would be interested in helping with this.
Where should I start with this memory allocation-related issue?

@madmaxoft
Copy link
Member Author

Hello.
If you are on Windows, MSVC2022 produces a warning when compiling GZipFile::ReadRestOfFile, that should point you in the right direction.
Basically this boils down to removing the Static part of the Storage's variant in Compression::Result in src/StringCompression.h, then fixing everything to work again.

@MrSach
Copy link

MrSach commented May 17, 2023

Thank you for the guidance on this.
I will investigate the error and also check the header and source files for the Static alternative for the Storage variant in question

@MrSach
Copy link

MrSach commented May 19, 2023

Hello, I have read the pages:

  • ./GETTING-STARTED.md
  • ./CONTRIBUTING.md
  • ./COMPILING.md
    and have followed the guidelines where I could.

After cloning the repository, I have changed a line in the StringCompression header file and a few blocks of code in the source file.
Having compiled the modifications on Visual Studio, I do not see any warnings for these header and source files now.

Should I show what changes I propose for the following before initiating a draft Pull Request?:

  • ./src/StringCompression.h
  • ./src/StringCompression.cpp

@madmaxoft
Copy link
Member Author

Sure, go ahead, a draft pull request is the best way to check if you're heading in the right direction.

@MrSach
Copy link

MrSach commented Jun 8, 2023

More commits have been added earlier this week to the draft pull request.
These propose a more suitable data type for storing compressed/uncompressed data.
Some commentary has been added to the header and source files.

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

No branches or pull requests

2 participants