How to clear dump (AndroidViewClient/Culebra) data from memory?
<p>I'm running an automated test script using AndroidViewClient. I do several dumps in the script. The script is used for a speed/response time test on an android device and the test is run for n>300. I get the following error at run #150.</p>

<p><strong>raise ValueError("received does not contain valid XML: " + receivedXml)
ValueError: received does not contain valid XML: Killed</strong></p>

<p>After some digging and monitoring the memory using "memory_profiler", The dump data seems to be stacking up on the memory and slow down the test and influence the test results. </p>

<p>1- Why do I get the error?
2- Where exactly the dump data is stored?
2- How to clear the memory every time I dump?</p>

<p>What you describe seems like an issue with <code>uiautomator dump</code> (probably your device implementation) which is what <strong>AndroidViewClient</strong> uses as the default backend for API >= 19.</p>

<p>However, to be absolutely sure you should remove AndroidViewClient from the picture and run the same command it is used as the backend.</p>

<p><strong>AndroidViewClient 12.0.2</strong> supports some debug options specified in the command line, one it's very useful to determine the command being run.</p>

<pre><code>$ dump --debug UI_AUTOMATOR:True &gt; /dev/null
</code></pre>

<p>this command will print something like</p>

<pre><code>executing 'uiautomator dump --compressed /dev/tty &gt;/dev/null'
</code></pre>

<p>then this is the command you can run repeatedly to determine if the problem is in your device.</p>

<p>For example, copying the command printed before you can use <code>bash</code> to run</p>

<pre><code>for n in {0..299}; do echo $n; adb shell uiautomator dump --compressed /dev/tty \&gt;/dev/null &gt;/dev/null; done
</code></pre>

<p>and check if there's a memory leak or something fails on the device.</p>

<p>Regarding your question and as you can see from the command, dump data is not stored anywhere and only copied to the socket.
There are versions that require the data to be stored locally on the device but in such case the file used is overwritten every time.</p>

android python dump androidviewclient