Instrumentation test run failed - instrumentation

I would like to ask a general question,
I am doing automation testing using robotium tool with the help of a tablet which is single processor. While performing some actions my test case is failing like INSTRUMENTATION TEST RUN FAILED DUE TO JAVA.LANG.OUT OF MEMORY error.
What i need is whether the out of memory error depends on the device processor speed also or purely it depends on the app and test code.
Any solutions can help me a lot

The OutOfMemoryError indicates that you've probably run out of heap space in the application. The device's kernel may set the limits on heap, but your problem is probably in your application and test code.
Does your test run out of memory while executing large tests?
You may want to profile your application for Memory Usage and start resolving memory leaks first.
It can also help if your robotium tests don't run for extended periods of time, but is only a band-aid if your application has memory leaks.

Related

Is it possible to set a baseline memory usage in valgrind for leak detection?

Is there a way to tell valgrind from inside my code when to start and when to stop checking for memory leaks?
I am using a legacy testing framework which must link with my testing program in order to run. The framework has memory leaks in it - valgrind shows about 50KB of memory that has not been released, but is reachable via heuristic. This is annoying, because I must keep this number in mind to see how much memory is leaked from my code. It would be a lot more convenient if I could tell valgrind to start collecting memory stats when my first test begins, and stop collecting when the last test is over. Is there an API for it?
valgrind memcheck allows to do a "differential" leak search. The differential leak search reports the delta between the previous leak search and the current situation.
You can do such a differential leak search using monitor commands with vgdb, either from the shell or from gdb. See https://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.monitor-commands.
You can also use the client request VALGRIND_DO_CHANGED_LEAK_CHECK from your program, see https://www.valgrind.org/docs/manual/mc-manual.html#mc-manual.clientreqs.

Would a Vulkan program run on a device without gpu (discrete or integrated)?

Perhaps this question could be rephrased as 'what would happen if I were to try and run a Vulkan program on a cpu-only build'.
I'm wondering whether the program would run but not produce output, crash or not build in the first place (although I expect the building process to be for a cpu architecture instead of a gpu architecture).
Would it use the on-motherboard graphics to produce output? In that case, what would happen if the program was run on a cpu-only server?
Depends on how the program initialized vulkan.
Any build can have the vulkan loader installed this is the dynamically loaded library that finds the actual driver, if that is missing the program would be unable to load the loader and may either fail to start or show an error message, depending on how they try and load that.
If no device is available then the number of devices is 0. This is again up to the application to manage. Either by going for an alternative graphics API (opengl) or a error message and failing to start.

TestComplete Out of memory issue

The problem we face when we try to run our automation script on for long hours is in between the execution we face with “Out of Memory” issue.This issue is bcoz GDI Object” leak happening due to which the RAM is becoming full and the tool is throwing the error.Is it possible to release these GDI objects through test complete script?
Maybe you are having a lot of performance counters on your project and the memory consumption for long executions are weird. Try removing all of them and reexecuting your project. I hope this solves your problem.

Xcode Memory Leaks detection in Unit Test

Is it possible to test if memory leaks occur when running a Unit Test?
I want to check if my memory management is handled correctly.
Thanks
You can try running your unit tests under Instruments with the Leak Detection Instrument.
However, this will only work for Application (bundle) tests, if you're using OCUnit. If you happen to use something else, please let us know.

How does valgrind work?

Can someone provide a quick top level explanation of how Valgrind works? An example: how does it know when memory is allocated and freed?
Valgrind basically runs your application in a "sandbox." While running in this sandbox, it is able to insert its own instructions to do advanced debugging and profiling.
From the manual:
Your program is then run on a synthetic CPU provided by the Valgrind core. As new code is executed for the first time, the core hands the code to the selected tool. The tool adds its own instrumentation code to this and hands the result back to the core, which coordinates the continued execution of this instrumented code.
So basically, valgrind provides a virtual processor that executes your application. However, before your application instructions are processed, they are passed to tools (such as memcheck). These tools are kind of like plugins, and they are able to modify your application before it is run on the processor.
The great thing about this approach is that you don't have to modify or relink your program at all to run it in valgrind. It does cause your program to run slower, however valgrind isn't meant to measure performance or run during normal execution of your application, so this isn't really an issue.
Valgrind is a Dynamic Binary Analysis (DPA) tool that uses Dynamic Binary Instrumentation (DPI) framework to check memory allocation, to detect deadlocks and to profile the applications. DPI framework has its own low level memory manager, scheduler, thread handler and signal handler. Valgrind tool suite includes tool like
Memcheck - tracks the memory allocation dynamically and reports memory leaks.
Helgrind - detects and reports dead locks, potential data races and lock reversals.
Cachegrind - simulates how the application interacts with system cache and provides information about cache misses.
Nulgrind - a simple valgrind that never do any analysis. Used by developers for performance benchmark.
Massif - a tool to analyse the heap memory usage of the application.
Valgrind tool uses disassemble and resynthesize mechanism where it loads the application into a process, disassembles the application code, add the instrumentation code for analysis, assembles it back and executes the application. It uses Just Intime Compiler (JIT) to embed the application with the instrumentation code.
Valgrind Tool = Valgrind Core + Tool Plugin
Valgrind Core disassembles the application code and passes the code fragment to tool plugin for instrumentation. The tool plugin adds the analysis code and assembles it back. Thus, Valgrind provides the flexibility to write our own tool on top of the Valgrind framework. Valgrind uses shadow registers and shadow memory to instrument read/write instructions, read/write system call, stack and heap allocations.
Valgrind provides wrappers around the system call and registers for pre and post callbacks for every system call to track the memory accessed as part of the system call. Thus, Valgrind is a OS abstraction layer between Linux Operating system and client application.
The diagram illustrates the 8 phases of Valgrind :
valgrind sits as a layer between your program and the OS, intercepting calls to the OS requesting memory (de)allocation and recording what is being manipulated before then actually allocating the memory and passing back an equivalent. It's essentially how most code profilers work, except at a much lower level (system calls instead of program function calls).
Here you can find some nice info:
Valgrind: A Framework for Heavyweight Dynamic Binary Instrumentation
http://valgrind.org/docs/manual/manual-core-adv.html#manual-core-adv.wrapping
Besides familiarize yourself with LD_PRELOAD.
Valgrind is basically a virtual machine that executes your program. It is a virtual architecture that intercepts each call to allocate/free memory.