xmrig / xmrig-proxy

Monero (XMR) Stratum protocol proxy
https://xmrig.com/proxy
GNU General Public License v3.0
618 stars 338 forks source link

Logging should not be fully read into memory #563

Closed arz96 closed 7 months ago

arz96 commented 7 months ago

After a period of time the ram will be more and more because logging file is getting bigger, and I can't even truncate it because it's in memory and when you change the file the program change it back once there's new logs, the only way to not let this happen is either disable logging or close the proxy before you modify the log file. XMRig-Proxy should just appened to the file instead of reading it first.

SChernykh commented 7 months ago

XMRig-Proxy should just appened to the file instead of reading it first.

This is exactly what it does. It only keeps data that hasn't been flushed (=written) yet: https://github.com/xmrig/xmrig-proxy/blob/master/src/base/io/log/FileLogWriter.cpp

arz96 commented 7 months ago

XMRig-Proxy should just appened to the file instead of reading it first.

This is exactly what it does. It only keeps data that hasn't been flushed (=written) yet: https://github.com/xmrig/xmrig-proxy/blob/master/src/base/io/log/FileLogWriter.cpp

I reproduced the problem, because it's been a long time before I asked this question, I forgot how did I ended up here. Because deleting the log file will make it impossible to add new logs unless the program is restarted, so I used echo > log.log to clear out the log. But when new logs occur, the file recovered itself, that's why I think it has been read into the memory instead of simply appending.

SChernykh commented 7 months ago

No, this is how a filesystem works. If you truncate the file, but some other program has a write pointer to it at a position of 1,000,000 and then writes to it, the size of the file will be 1,000,000 + size of new data. The first 1,000,000 bytes will be technically garbage, but if old data is not overwritten, it will be old data.