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

Process Crash Due to Insufficient Memory #60

Open
avizack18 opened this issue Mar 28, 2024 · 7 comments
Open

Process Crash Due to Insufficient Memory #60

avizack18 opened this issue Mar 28, 2024 · 7 comments

Comments

@avizack18
Copy link

This issue reports that the process crashes when the system's available RAM falls below a certain threshold.
While creating a large swap file (e.g., 8GB) can mitigate the issue, it's considered poor practice due to potential performance drawbacks.

@ilch1
Copy link
Collaborator

ilch1 commented Mar 28, 2024

Hi @avizack18,

Thanks for your question. The recommendation is to have 8GB of RAM: https://github.com/volatilityfoundation/dwarf2json/blob/master/README.md?plain=1#L27. You do not need to have a large swap file or use one at all. Most modern systems have at least 8GB of RAM. If you are using a VM, make sure to allocate at least 8 GB of RAM to avoid OOM error you are seeing. Out of curiosity, how much RAM does your system have?

@avizack18
Copy link
Author

While I have 16GB of RAM installed, a significant portion is likely being consumed by virtual machines (VMs) running on my system. This leaves less than 4GB of free memory available, which seems to be causing the process to crash.

Current limitations:
Increasing VM RAM allocation: This would be ideal, but might not be feasible at the moment.
Large swap file: As mentioned, a large swap file can be a temporary solution, but the performance drawbacks are a concern.

Alternative solutions:
I'm curious if exploring a database designed for low-memory machines could be helpful. Are there any recommendations within the dwarf2json project or the broader community?

Looking forward to your thoughts!

@Abyss-W4tcher
Copy link

Hi,

I also encountered really high RAM usage while using dwarf2json. I might be wrong, but it seems like everything is stored in memory, which eventually makes use of the swap (if configured) and slows down the system.

A system of temporary cache (togglable) would allow to store already processed information on disk, chunk by chunk, while also freeing unnecessary loaded data ? This could keep the memory usage around 2-3 GB of RAM and ensure nothing goes to swap ?

@mkonshie
Copy link
Collaborator

mkonshie commented Apr 2, 2024

Hi,

Yes, dwarf2json currently stores JSON in memory before writing it out. Given the current constraints, it is not feasible to incrementally write out the JSON for the types and the symbols as they are being parsed from the DWARF. dwarf2json follows the volatility3 schema, which can be found here:
https://github.com/volatilityfoundation/volatility3/blob/develop/volatility3/schemas/schema-6.3.0.json
.

Feel free to contribute ideas or pull requests with improvements but make sure the dwarf2json output is compatible with the vol3 schema.

@Abyss-W4tcher
Copy link

Abyss-W4tcher commented Apr 2, 2024

Hi,

Yes, dwarf2json currently stores JSON in memory before writing it out. Given the current constraints, it is not feasible to incrementally write out the JSON for the types and the symbols as they are being parsed from the DWARF. dwarf2json follows the volatility3 schema, which can be found here: https://github.com/volatilityfoundation/volatility3/blob/develop/volatility3/schemas/schema-6.3.0.json .

Feel free to contribute ideas or pull requests with improvements but make sure the dwarf2json output is compatible with the vol3 schema.

The JSON file will generally be of the ~30 MB order, but RAM can go up to 8GB sometimes. Aren't all the DWARF symbols loaded in memory and then never cleaned out as they are processed ? If so, isn't it possible to store the DWARF symbols in a temporary file (as possible with dwarfdump), then load them by chunk (let's say 2GB) in RAM and feed it to the parser ?

@avizack18
Copy link
Author

any chance to fix that issue?

@mkonshie
Copy link
Collaborator

Some form of what you are suggesting could be worth investigating, but it would not be trivial because dwarf2json does not operate on the DWARF types and symbols directly from memory but on the internal representation generated by the dwarf library. The dwarf library also caches these types (dwarf.Type) internally for performance reasons which also increases memory usage. There would need to be a way to map the dwarf entries to the dwarf.Types returned by the dwarf library.

Outputting DWARF to an intermediate representation, such as that with dwarfdump, is an interesting idea. However, that would require enhancing dwarf2json to process DWARF in addition to its current functionality that processes DWARF IR from the dwarf library. It may also be possible to rewrite dwarf2json in another language that uses a different DWARF library. There are no immediate plans to do either of these by the core developers of this project. We always welcome pull requests from members of the community.

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

4 participants