Post
Share your knowledge.
How to compile failure due to memory constraints in WSL Ubuntu?
I am conducting a competitive audit and encountered a compilation issue while working with a codebase consisting of over 400 files. When attempting to compile the code in my WSL Ubuntu environment, the process fails with the error message 'solc exited with signal: 9 (SIGKILL)'. My system specifications include an i5-13500HX, RTX4060, and 16GB RAM, but upon checking, I realized that my WSL Ubuntu is configured with only 8GB of memory. Could this memory limitation be the cause of the compilation failure? If so, how can I increase the memory allocation for WSL? Alternatively, if memory is not the issue, what steps can I take to successfully compile this extensive project in Foundry?
myubuntu@myubuntu:~/audit/24Jan-Arcadia-Sherlock$ free
total used free shared buff/cache available
Mem: 7989616 786980 7056744 432 145892 6998208
Swap: 2097152 775024 1322128
I suspect that the compilation failure might be due to resource constraints or potential issues with solc consuming excessive resources. Any insights or guidance on resolving this compilation issue would be greatly appreciated.
- Foundry
- Solidity
Answers
1Enlarging the memory limit by modifying the .wslconfig file can be an effective solution for enhancing performance. To do this, follow these steps:
- Create a new file named
.wslconfig
in the directoryC:/Users/[YOUR USERNAME]/
with the following content:
[wsl2]
memory=15GB
- After saving the file, restart the WSL by executing the command in your Windows Terminal:
wsl --shutdown
- Once you reopen Ubuntu, the memory limit will be increased to 15GB, enabling you to compile larger projects efficiently.
When compiling projects, the enhanced memory capacity can significantly improve performance, as demonstrated by the reduced compilation times observed in the provided example. This adjustment should accommodate a wide range of projects, but it is advisable to monitor memory usage to ensure optimal performance.
Do you know the answer?
Please log in and share it.
Cyfrin Updraft is an education platform specializing on teaching the next generation of smart contract developers