splondike / polipoid

Android wrapper for the polipo proxy
GNU General Public License v3.0
35 stars 12 forks source link

control memory usage of polipo server #2

Closed ghost closed 10 years ago

ghost commented 10 years ago

By default polipo will use 24MB or one quarter of the machine's physical memory, whichever is less - and once it is allocated it will keep this memory in-core until killed. On Android this is a bit too much as those devices don't have swap and very frequently are memory constrained. In addition, polipo's cache flushing mechanism also means that a large portion of the in-memory cache will be written to disk in one go which can be slow due to the filesystem and memory device used.

This should be either user configurable or set to a lower value, 1MB appears reasonable, can be done with

chunkHighMark = 1048576

splondike commented 10 years ago

I'm not sure that we'd have problems writing 24mb to disk, but reducing the memory usage if it seems to make no difference makes sense.

I'm going to try using this configuration for the next week or so and see if I run into any issues. If you're not already, could you try doing the same? We just don't want to squeeze Polipo too hard :), particularly as the java wrapper service (which we need to be running) takes several times the amount of memory of the Polipo binary.

ghost commented 10 years ago

I am now running polipo on my workstation with chunkHighMark = 819200 - so far runs without any glitch and don't notice any speed difference.

The java wrapper on my phone uses 10M but only 2M real memory usage, everything else is shared or demand paged. However the 24M that the polipo binary might use are real memory usage, on an usual Android device it can not be swapped out. I am watching these with os-monitor from f-droid.

splondike commented 10 years ago

I've not had any problems these last couple of weeks, is it working fine for both of you as well?

ghost commented 10 years ago

no problems here either, seems rock solid. Polipoid disappeared twice during some weeks but that could have any number of explanations.

splondike commented 10 years ago

Cool. I've changed the default config: 4a703c567b8b6decde0d27a30af1ac3cb29f6628.

Regarding the crashes, that was probably the xtend wrapper (as opposed to polipo) that was crashing, otherwise a crash notification should have shown up.