Anshuman Chatterjee | Posted on | 2 min Read

Uncover Memory Leaks by Mobile Apps

 

Mobile apps can often crash for many reasons. Nothing is as excruciating as memory leaks. It starts with your app crashing often, or becoming slow or maybe making your entire phone slow down, taking longer time to load activities. Memory leaks are notoriously hard to detect, and thus can easily surprise you. Have we ever thought why most of the users uninstall the application after some use?

Which is why it is critical for Developers to understand the memory consumption by any mobile application. How do you detect memory leaks during Mobile Application Testing? And if so, how can you prevent them from hogging mobile resource consumption?

A little knack for Mobile Application Testing always comes handy.

 

mobile application testing
Figure 1: Image Credit- GadgetHacks

 

Want to test your Mobile App?

Join pCloudy Platform!

Memory is critical to device

 

Memory is one of the key resources of the mobile device.And memory leaks in Android is an important thing to be kept in mind. Java is a garbage collecting language, which removes the need for developers to dig deep to manage allocated memory. This reduces the chances of any segmentation fault crashing an app or any unfreed memory allocation from eating up space of the heap area, thus creating a safer code.

 

However, a garbage collector is never an insurance against memory leaks. There are other ways by which memory can be leaked within Java. This means that your android mobile application is still pretty prone to wasting unnecessary memory allocation and crashing with out-of-memory (OOM) errors.

 

Toptal
Figure 1: Image Credit- Toptal

 

Why are Memory Leaks Bad?

 

Cause: Memory leaks occur when some variable of the application still has references to some objects that are unnecessary, no longer in use or used to be with the app anymore, is bloating the allocated memory heap and the Garbage Collector is not being able to release that memory.

Effect: Android devices mostly run on phones with limited memory, so as a result of too many leaks, the app runs out of available memory. This triggers more frequent Garbage Collector events which paralyze the device (Stop-the-world GC events) by almost stopping the rendering of UI and processing of events. This leads to an Out of Memory Exception and translates to the user as the app being unresponsive.

 

Android App Testing

 

Testing for Memory Leaks

 

Memory Leaks are caused by the failure to not be able to de-allocate memory that is no longer in use, which is why they cannot be identified during black box testing. The best phase to find the memory leaks is when developers are developing the application, at a code level.

It’s best to check for memory leaks during unit testing. However, testers can follow these tips:

 

Release Unused Memory: Memory leaks can be present because of the bad design of the application and thus might consume lot of memory when the application is in use

 

Test on Multiple devices:The memory consumption by the application should be monitored while doing the system & functional testing. One shouldn’t rely on a single device testing as there are plethora of devices in the market.

 

Detecting Memory Leaks

There are quite a few techniques and tools devised by developers to pin point memory leaks. Android’s very own Android Studio has a powerful tool to monitor not only memory usage but also for network, GPU and CPU usage as well, called the Android Monitor.

Memory Monitor in this helps track memory usage, find de-allocated objects, identify memory leaks and helps get an overall sense of how your app allocates and frees memory. It’s done in three steps:

1. During and use and debugging of app, track the memory monitor. If the memory usage graph rises for your app and doesn’t fall even if put in background, it’s a memory leak.

2. Using the Allocation tracker, you can check the percentage of memory allocated to different types of variables in your app. This gives you a sense of how much memory is consumed by which object.

3. Create a Java Heap Option to create a heap dump that keeps a snapshot of the memory at any given point of time, thus providing the data consumption data.

Despite Android’s monitor to detect memory leaks, there are a few platforms from developers that help extract memory consumption data without so many steps for faster testing cycles.

pCloudy’s very own platform for example, generates the statistics for Memory consumption while doing the normal functional Mobile Application Testing on real mobile devices.It also generates other vital data such as CPU consumption, battery consumption & data consumption for testers and developers who reiterate several test cycles across multiple physical devices.

 

mobile application testing
Figure 1: Image Credit- Android Developers Studio

Want to test your Mobile App?

Join pCloudy Platform!

Android App Testing

 

If you are anything like me, you’d agree that the armor of present day mobile phone technology has a few chinks on it. Nothing is worse than applications draining the battery resources of your mobile device faster than you can fill it back up. The sunnier side of course, is that you can create teachable moments for your kids better by hiding their phone chargers and watch the colors drain from their faces.

Studies show that battery life is a top priority for smartphone buyers. In fact, just recently, an IDC survey showed that 56% of Android buyers, 49% of iPhone buyers and 53% of Windows Phone buyers said that battery life was a key reason when they bought their particular device.

It is rare to find mobile app testing tools that assure proper usage of resource by the mobile app as, included in the overall test plan and strategy.

It’s rather a tedious and long process for conventional mobile app testing methods and as such, Let us talk about how resource consumption as an app takes top priority, because nothing stops a user to uninstall their resource draining apps from their phone. Also we’ll talk about how developers and testers efficiently test mobile apps for Android applications.

 

Android App Testing

Figure 1: IDC Survey

 

Why battery testing is important:

 

Thousands of new mobile apps are being launched every day. And these apps have gone beyond just utilities, games and shopping apps, nowadays, apps need to be integrated into self-driving cars, digital assistants, wearable devices etc. Billions of users need to install apps that are not only compatible with their varying devices, but also provide quality experience of the app so that it doesn’t prompt the user to uninstall it and move to an alternate app.

When you get worried about potential battery abuse, its fair economics to identify the markers that can cause increased consumption of energy by the mobile application. Critical are the functionality, usability, performance and security to make sure that the app does what it was meant to do, seamlessly. The growing need for perfect enterprise and consumer apps and the continuous need to upgrade the application to match it with what the consumer exactly wants is a job that creates high pressure for developers and testers alike, who are responsible to delivering them.

We would get deep into the best practices and tactics that should be kept in mind while testing for battery drain in your mobile app in a later blog post. For now, let us look at how developers can test for battery consumption during Android App Testing.

 

How to test battery consumption for mobile apps:

 

So far there hasn’t come a good automation method to test app battery drain. So testing Real Mobile Devices meets many requirements for efficiency in the process. Let us check out a few parameters to test battery drainage due to mobile apps.

 

  • Battery test flow

    This will vary based on the functionalities of the applications. But overall the below approach or points should be considered while testing for battery consumption.

    • Check the status of the battery before the test begins
    • Enable the location services for the application if app supports
    • Start the data sync of the application if app supports
    • Start the streaming service of the application if app supports
    • Check if the application send/receive the data when in the background
    • Check if the application send analytics to its server
    • Observe the battery consumption while doing above supported features by your application.

This will give us an idea as what is the battery consumption by the application.

 

  • Testing as end user

It is very critical to test the environment needs of the app from a real user perspective. Environments like device types, operating system, background popular apps installed and running, network conditions (WiFi, 2G, 3G, 4G, Roaming) as well as diverse set of devices with different battery states, brings DevOps teams as close as they can come to end users.

 

  • Android App Testing across varying devices

Android is guilty of OS fragmentation due to its open approach to OEM vendors. Different devices have varying battery capacity and each loses its battery chemistry over time, negatively impacting performance and battery hours. This is why we must check the battery consumption for the mobile app on variety of mobile devices. The best practice is to use multiple devices from device labs/ device clouds.

 

Different tools available in the market.

 

Android’s built in Battery App

Your Android Mobile Phone has a ubiquitous battery testing resource, as it comes preinstalled on all Android mobile devices. Android’s native battery analyzer, for example, (Settings> Device> Battery) is built into Android’s OS and helps analyze each app and let you know which are the ones draining the most fuel.

 

Commercial Battery Saving Apps

There are a few commercial Android Battery Analyzers which are available for free in the market, like:

 

GSam Battery Monitor can reset testing cycles as you go, which means there is no need for draining and recharging the battery like in android’s native battery app, and monitor app power usage without having to wait to get an information reset.

 

Clean Master on another hand, lets you know through its notification feature as and when an app is causing the phone’s battery/CPU to drain, which gives instant information on any CPU overuse.

Android App testing

 

pCloudy platform for Testing Battery Drain

pCloudy platform allows comprehensive features for Android App Testing. Moreover, Using pCloudy’s platform, one can monitor the battery consumption by the application. additionally, the user can also monitor memory, CPU and data consumption by the application.

The user can do the complete functional app testing on the application by touching all the critical/non-critical paths in the application. The pCloudy platform provides the necessary data for the work flow.

 

Performance Metrics

 

Conclusion

Google has said that this year their focus is on the ‘vitals’ of mobile phones, battery being one of the critical four. It’s always best to use varying angles of attack to test your app’s battery usage. And the only way to do that right now is to cover as many mobile device variants in the market and test against them.

 

To check battery consumption during Android App Testing Click Here.

 

Get 180 Device Testing Minutes Free




pCloudy 4.3

 

  • User can directly send input to the pCloudy Android devices by using their system keyboard.
  • CPU and Memory graphs on iOS.
  • New Improved Automator Page.
  • Automator now works on devices for all region
  • Live view for the Automation run for devices from all region
  • Bug Fix: Remaining Credits now revert back after an Appium session finishes earlier than booking expiration time.

Click Here to check our Previous Release.

Nilesh Tarale | Posted on | 2 min Read

How to create a world class Mobile Testing Lab?

 

It can be a big challenge to build a large scale Mobile Testing Lab from scratch. Look around you and you will see that with every single day, companies in adding mobile apps in their business strategy and with it the mobile app dev and testing market is becoming increasingly competitive, dynamic and fast paced. Older testing methods are becoming obsolete and the utter multiplicity of mobile platforms, devices and networks have made it important for any company to choose the right solution (Mobile Testing Lab) in order to strengthen themselves in the market.

While creating a testing program for these mobile applications can seem like a relentless chore and a massive undertaking, it doesn’t really have to be. Here are a few considerations to choose the right lab strategy for testing your mobile apps.

 

Key Considerations:

 

• Compatibility of Device OS, Screens and OEMs: The sheer number of different device variants, OS versions and screen resolutions form a large set of factors even though each of them are significant in their own rights. In 2012 there were about 4,000 Android device models on sale. 2015 saw about 24,093 distinct Android devices. Question is, can the lab I choose, cover maximum number of devices and come close to 100 percent of my end users’ device base?

 

mobile labs

 

• Device Control Infrastructure: After you select your target devices, it is also key to look at the other parts of a reliable architecture of your hardware. Regardless of the technology to be used in building the device lab, one needs servers to control and take care of managing devices and execute tests. Moreover, it is crucial for these servers to collect, process and store results of the tests seamlessly and without interruption.

 

mobile testing lab

 

A snapshot of Infrastructure needed to create a Mobile Device Lab

 

mobile testing lab

 

Facebook Device Lab Infrastructure

 

Click Here to know about pCloudy Device Cloud Infrastructure

 

• Wi-Fi Infrastructure: This is another very crucial area that is often ignored when creating large-scale test lab. As the number of device in a WiFi network adds up, so do problems when all these devices transferring data at the same time. Most WiFi access points are not designed for this kind of bandwidth and you are bound to see different types of timeouts on server responses.

 

• Importance of Automated Testing: The very obvious benefit of automation of testing of mobile devices on the cloud is that through this one can carry out tests on a wider range of OS and devices in a much shorter time and with lesser life-cycle management investment. This not only significantly reduce QA spending, it also expands coverage and speeds up the resolution of issues. You can use a single script and apply the same on different devices and operating systems.

 

Integration with CI/CD pipeline:

 

Today, almost all organizations have mobile apps and for some, the mobile app is their only way of interacting with customers. With this increasing emphasis on mobile, the pressure to routinely update mobile apps means embracing Continuous Integration (CI) and Continuous Delivery (CD) methodologies. Any Mobile Labs has to support the CI/CD process.

 

5 Tips to build a successful lab:

 

1. Using Real Devices
2. Tackling Multiple Devices
3. Using a Secure Mobile Device Testing Cloud
4. Automation Strategy
5. Increase Lab efficiency by integrating with your existing tool ecosystem

 

1. Using Real Devices: Some Devs/testers are using emulation technology for compatibility testing. However, it has been proven beyond doubt that testing on emulators is often not reliable. Real devices help you and your team to find real bugs in your App before customers do. It is only way to have a confident App release and increase the chances of success of your test lab.

 

2. Tackling Multiple Devices: With thousands of different devices, it can be a bit overwhelming when building a mobile testing lab that encompasses the coverage of testing in all of them. Luckily, the major mobile operating systems use logical screen sizes which are mapped to physical screen, hence, the representative devices will get the necessary coverage. The test strategy is not to test absolutely everything, but to test the crucial elements that are most represented in the popular devices in the market, and add or subtract devices as they come in and out.

 

3. Using a Secure Mobile Device Testing Cloud: Using a secure cloud is vital to enterprises, especially if they aren’t located under the same roof. Testing real devices for everything can become really costly and time consuming. Using a testing cloud keeps your budget in check, reduced project cost and thus helps achieve high return on investment. Be it public cloud for small businesses, or large enterprise projects that demand a private cloud infrastructure, high performance and security are essentials to have complete control over the cloud.

 

4. Automation Strategy: Creating Regression Automation suites once Application is ready is a passé. Agile methodology and CI/CD process demands automation creation in parallel to development. Automation strategy should be built keeping above aspect in mind.

 

Here is a depiction of what the automation process should look like.

 

Mobile Labs

 

As part of Automation Strategy, Mobile Testing Lab should provide the capability to allow automation run on multiple devices in parallel.

 

5. Increase Lab efficiency by integrating with your existing tool ecosystem: A lab is as good as how well can it be integrated within existing ecosystem. Can it integrate with your Test Management system or can it log bugs automatically after a failure? Can it integrate with your build management tool for CI process? Here is a depiction of how “Test Tools” fit in the larger ecosystem.

 

Mobile Testing Lab

 

Conclusion: A well thought strategy for setting up of Mobile Testing Lab is a necessity for every organization undertaking Mobility projects. In current times, organizations have plethora of choice related to setting up of Mobile Testing Lab. They can choose to setup an In-house lab or use a private-hosted service or use a cost effective Public Cloud lab.

 

Would you like to know more about Lab options with pCloudy? Click Here

Are you Ready for the Challenge?

The pCloudy Mobile App Hackathon is a programming-focused Coding contest designed to inspire a creative and dynamic generation of tech professionals to put their skills to the test. For three weeks, top developers will compete for the chance to win prizes and job interview opportunities in a skill-based challenge. Think you got what it takes?

Code Challenge

pCloudy

mobile app hackathon mobile-app-testing-platform
The pCloudy Mobile App Hackathon Your Simplest Mobile App Testing Platform
register mobile-app-testing-platform

prizes

Eclipse IDE

 

An Overview

pCloudy provides a plugin for Eclipse IDE. Using the plugin you can perform both manual and automation testing of mobile apps. The plugin provides a user interface to connect to the pCloudy platform. You can upload apps, book devices and perform your testing right from your IDE.

 

For Manual Testing

Upload your app to the cloud drive, select the device, and perform the manual testing of your app right from Eclipse.

 

For Automation Testing

This plugin helps you get a pseudo code for your Test Scripts to run on multiple pCloudy Real Devices in Parallel. Just install the plugin, login to pCloudy.com, upload your app, select devices and get the pseudo code.

 

Prerequisites

  • You have an account over pCloudy with enough credits.
  • Latest web browsers on local machine
  • Latest version of Eclipse
  • Eclipse pCloudy plugin

Preparation

  • Reference the JAR files to Eclipse
  • Make a note the API Username and API Access Key

Steps to be followed

Launch Eclipse > go to Help menu of Eclipse > click Install New Software > Copy and paste the below Eclipse plugin address in Work with textbox.
http://eclipseplugin.pcloudy.s3-website-us-east-1.amazonaws.com/

  • Click on Add, a new pop up window of Add Repository will open
  • Enter Name and Location, click on OK
  • Check pCloudy checkbox and then click on Next

Available Software

Now, you need to install pCloudy Eclipse Connector. Click on Next to begin pCloudy Eclipse Connector installation.
pCloudy-Eclipse-Connector

Further, check I accept the terms of the license agreements checkbox and click on Finish.
review-licensed

Installation of pCloudy Eclipse Connector begins.
installing-software

On completion of pCloudy Eclipse Connector installation successfully, an alert message appears. Click on OK to proceed pCloudy plugin.
pcloudy-plugin

Now, enter Cloud URL of pCloudy along with registered Username and Access Key over pCloudy to login successfully. Click on Apply and then OK.
preferences

Now, you are able to perform Automation/Manual testing of apps based on Appium TestScripts/pCloudy/OpKey or Test as per your requirement.
 

Automation Testing of App

To perform automation testing of your app, here’s a checklist you need to prepare for Automation
Here, we are discussing about Test Automation of apps by over pCloudy.
Select Automation & pCloudy and then upload your app to be tested.
Click on Next to proceed.
upload-app

Select duration and filter list of devices by using given filter parameters (Android/iOS, Manufacturer, and Version). Select desired device (Ex. Samsung) and click on Next.
select-devices

Finally, you get pseudo code for performing Test Automation. You can copy it to clipboard or copy it manually by selecting entire pseudo code.
connect-device

You will need the pCloudy java connector jar file for the above code to work. The pCloudy-java-conector.jar contains the API wrappers, classes & methods to use the pCloudy RestfulAPIs(without knowing how to call rest webservices from java). The gson.jar is a well known, opensource google library. You should add the pCloudy-java-connector.jar in its build path as a reference within your java project containing appium scripts. See this link to learn how to add reference in eclipse.
You can download pCloudy-java-connector.jar & gson.jar(a dependancy of the pCloudy-java-connector.jar)

 

Manual Testing of App

If you want to perform Manual Testing of apps over pCloudy through Eclipse then select Manual way and pCloudy and upload app to be tested. Click on Next to proceed.
upload-app-manual

Select duration and filter list of devices by using given filter parameters (Android/iOS, Manufacturer, and Version). Select desired device (Ex. Samsung) and click on Next.
select-devices-automation

Now, you are recommended to open pCloudy in browser. Click on Open in browser and then on Finish.
open-in-browser

When you click on Finish, pCloudy login page opens in eclipse. Now, you can login and perform manual testing on selected device as well
login-to-start-testing

Testing Mobile Apps

 

If you are someone using a smartphone to get through most of your day, then I’m sure would you’ve experienced it – You are in an elevator using your smartphone trying to find a restaurant for dinner but the app you are using unexpectedly crashes, or you are in a crowded subway using your smartphone to upload a video to some social media portal but the app you are using takes too long to respond, or you are just waiting for a friend in the basement of a parking lot and in the meanwhile you decide to shop for some new shoes but the e-commerce app you are using does not respond the way it should. Isn’t it frustrating when the apps you are using does not work when you require it the most? In these situations, the first thing you do is simply uninstall it, or in the worst case write a bad review.

Strangely, though most of the apps are functional and performance tested, they are still found to be defective by the users. It could be possible that not all scenarios are covered during testing. So, where is the gap? Deeper investigations have revealed that mobile apps behave differently in different network environments. In the above scenarios particularly, it seems like there is more evidence indicating that these issues are caused due to irregular mobile networks in locations such as the Elevator, or the crowded Subway, or the basement of a parking lot.

 

Why do apps behave differently in different network environments?

The network has a huge impact on the behaviour of your apps. Most of the apps that we use today are functioning by constantly communicating and fetching information from some servers or users that are miles away. The communication that happens is on wireless networks that are unfortunately not always reliable or consistent. Though most MNOs have established wider and better networks, it is practically difficult to achieve absolute seamless connectivity with excellent signal stability using existing wireless technologies. This is because, inherently, wireless networks have several inconsistencies like the lack of bandwidth in some places, the drop in packets caused by handovers and routing while moving, and more interference from other networks. Additionally, the networks through which data is transferred wirelessly also vary based on the technology used like GPRS, UMTS, HSDPA, LTE etc.

 

Why should apps be tested in different network environments?

The unpredictability of wireless networks has a huge impact on the functionality, performance and user-experience of an app. This is why we often see certain functional defects, performance defects, and sometimes crashes only when the app is running on a certain network or in some specific locations. Besides, mobile apps are expected to function on everything from an excellent Wifi connection, to a snail-paced 2.5G connection. Hence mobile apps have to undergo a wide range of tests on different networks with a variety of conditions before they are released to the users.

 

Are you testing your apps on different network conditions?

Traditionally, mobile apps are tested using the best networks in perfect conditions. But in real environments when the apps are being used anything can go wrong – the network bandwidth might not be enough, the latency might be high, data losses might occur, or there might be interference from other networks. App development companies have now realised the impact a network can have on their apps and are slowly filling up the gaps in mobile app testing. They are now focused on ensuring the app’s functional stability and relentless performance despite network inconsistencies. But testing mobile apps on different varieties of networks with a range of uncommon conditions is overwhelming and challenging. Moreover, these apps have to be tested on numerous mobile devices. It’s a tedious but crucial task. Additionally, tools that support such testing are scarce.

 

How can you test your apps in different network environments?

  1. Testing Mobile Apps using live networks – Live networks can be used for testing mobile apps. The apps can be installed on real devices and can be tested on various networks like GPRS, UMTS, LTE, CDMA, etc. But the procedure of using real networks for app testing is slow, cumbersome, and mostly provides inaccurate results. Testers need to travel to different locations or wait for the network conditions to occur for conducting the tests. Furthermore, when the developers try to reproduce the bugs in order to fix it, the exact network conditions are hard to be replicated; eventually, most of the bugs will be closed as “Cannot Reproduce” while the bug still remains.
  2. Simulated networks – Network related tests for mobile apps need not be such a hassle if the testers are given full control of the network being used. Using a simulated lab network, testers can easily test their mobile apps by simply selecting and applying the type of network profile to be used. They can also create and customize different network profiles by simply changing parameters like Uplink Bandwidth, Downlink Bandwidth, Latency, Loss Percentage, Packets Corruption, etc. This setup helps testers to replicate a myriad of network conditions for testing mobile apps.
    On a larger view, when a mobile device cloud like pCloudy is being used you can test your mobile apps on varieties of networks, on hundreds of real mobile devices in parallel, through manual tests or automation runs. It is one platform that takes care of your entire app testing needs by helping app developers to easily test and experience the app functionality and performance on different networks and different mobile devices.