MuWire limit Ram usage java / max connection

The MuWire file sharing application
Post Reply
robabok978
Posts: 37
Joined: 12 Feb 2022 02:58

MuWire limit Ram usage java / max connection

Post by robabok978 »

Hi,
is it possible to limit the Muwire ram usage in the jave env?
muwire uses 300mb have max 800MB and 4GB.

Can i limit the connections to peers?

What does let the ram usage becoming bigger? tunnels, upload slots, files (hashes?)
Does java clean up its unused ram with zeros? (zram compress, with 1gb physical ram)

Thanks
User avatar
lgillis
Posts: 156
Joined: 20 Oct 2018 12:52

Re: MuWire limit Ram usage java / max connection

Post by lgillis »

First you should determine how much RAM is used in the default setting. You will find a menu item "Status/System" at the top. These values can differ from the measured values of other monitors like htop, sometimes considerably.

To reduce the consumption you can adjust the startup script (bin/MuWire or bin/MuWire.bat for Windows). There in the setting for "DEFAULT_JVM_OPTS=" you will find the value "-Xms256M". This determines the start value of RAM. Directly behind it a maximum value "-Xmx" can be entered for the Java virtual machine (JVM). Example: "-Xms128M" "-Xmx256M"
Here it is necessary to try out at which values the program still runs stably. If it crashes, first increase the maximum value ("-Xmx").
Luther H. Gillis · Private Investigator · Discreet & Confidential
zlatinb

Re: MuWire limit Ram usage java / max connection

Post by zlatinb »

0.8.13 sets the Xmx setting (maximum heap memory) to 4GB. It is possible to change that, but you are using the AppImage or windows installer it is a bit tricky. Let me know which Muwire package you use and I'll give you instructions how to change.

The number of peer connections can be changed by editing the "peerConnections" setting in "MuWire.properties". The location of that file is different on the different operating systems. MuWire will try to establish up to half of the value of the setting, so the default of 128 means it will actively try to maintain up to 64 connections.

The number of connections naturally affects the memory usage, but the main contributing factor is the number of shared files (not their size). However, with the default Xmx setting of 4GB you should be able to comfortably handle 1 or 2 million shared files.

As far as the zram compress question, I don't think the jvm zeroes out the released memory, although that may vary from jvm to jvm.
User avatar
lgillis
Posts: 156
Joined: 20 Oct 2018 12:52

Re: MuWire limit Ram usage java / max connection

Post by lgillis »

With an Xmx of 256m, it should be possible to manage over 100k files, right?
Luther H. Gillis · Private Investigator · Discreet & Confidential
zlatinb

Re: MuWire limit Ram usage java / max connection

Post by zlatinb »

lgillis wrote: 12 Oct 2022 17:50 With an Xmx of 256m, it should be possible to manage over 100k files, right?
Hard to tell, 256M is really quite low. Try and it let me know if it works!
User avatar
lgillis
Posts: 156
Joined: 20 Oct 2018 12:52

Re: MuWire limit Ram usage java / max connection

Post by lgillis »

I see, in 4GB fit so many files that it is almost impossible to check the specified limits and derive a calculation from them.
Luther H. Gillis · Private Investigator · Discreet & Confidential
robabok978
Posts: 37
Joined: 12 Feb 2022 02:58

Re: MuWire limit Ram usage java / max connection

Post by robabok978 »

I am with arm64 raspbery pi 1G RAM
openjdk-17
the beta zip MuWire-0.8.14-beta2.zip

With fluxbox in a remote vncsession i have 600M free
zram with zstd (with that and muwire running i can get ~5-10% free ram and zramswap - by nmon which it let runs stable with 6000 files

How big is a hash in ram. Is there a rule 1000files/100M?

How does max.Resource settings come in memory usage?

Does a low upload slot number affects positive on ram and speed (with max tunnels)? Should someone play with parameters like slot/maxuser

Is possible to crash my instance of Muwire if someone has like a million files and i would browse them with my 1g ram?

Is it better to use MuWire with the internal i2prouter(java? or C?) or the with a seperate java i2prouter?

Some java question:

Does it really allocate 4GB? With non used as zeros? Wonder that zram could handle this and was more that total in MuWire/system is the "real" mem usage)

Are there low/lite alternatives?

Is MuWire still able to run in 32bit env (termux on android is 32bit)?



Tests:


unchanged Xmx4g


Fresh start

total 921M/921M ram/swap


console
free
680M/921M

java i2prouter
380M/921M

tigervnc flux and 1 remote session
280M/91M

Muwire
last seen 20M/0
...system is unusabble at this point


delete files/directories folders in .config and restart muwire

vnc fluxbox:
free ram/zramswap
120M/921M i2prouter vnc fluxbox

changed Xmx in MuWirescript to 768M


start muwire without shared files
20M/840M

Muwire/systeminfo:
used 240M
total 400M
max 680M


starting hashing with 4cores

1500files free 50M/600M muwire:used 160/total 360/max 680


3000files free 40M/750M muwire:used 80/total 200/max 680


Works fine now - it was the Xmx parameter
Saw it in top, but never thought, that it would allocate 4gb
zlatinb

Re: MuWire limit Ram usage java / max connection

Post by zlatinb »

1GB total system RAM is really pushing it. Yes definitely change the Xmx parameter and avoid sharing too many files. If you have a lot of files to share I would recommend to use i2pd as external router and instead of the muwire desktop client use the seedbox daemon (but you can't search or download with that)

I don't remember of the top of my head how much memory each shared file uses, I can look it up in visualvm. You may be able to go up to 100-200k, even more, but not millions for sure.

When someone browses you for a short period of time a little extra memory is used. How much depends on the number of shared files. So theoretically yes, MuWire could run out of memory.

Regarding 32-bit support, if you can find a jvm that runs in 32 bit mode muwire should run fine on it, but I've never tested that.

The resource usage setting is for i2p network resources - it determines how many i2p tunnels to build. It has very little impact on system resources used.

Upload slots do not affect memory use that much. The settings are there more to prevent someone from hogging all your bandwidth.

Regarding java ram usage - I don't know, no idea if it allocates zeroes.
robabok978
Posts: 37
Joined: 12 Feb 2022 02:58

Re: MuWire limit Ram usage java / max connection

Post by robabok978 »

1GB total system RAM is really pushing it
Yes zram with zstd does wonders here.
java i2prouter, tigervnc, muwire by remote remmina
and 300M zram free is ok for me.
Thanks
and
advice how to setup a closed f2f network?
I've done copy id to friend and and set in settings only connect to trusted nodes which worked,
but is there something else i miss on features for this?
Post Reply