Category Page

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!

Internet of Things

 

Have you heard the term “Internet of Things” or “IOT” lately? The answer might be yes for most of you. Have you wondered what’s the buzz all about? What do we call “things” here? And, what is it to do with Internet? We will try to understand the phenomenon in this article.

 

Firstly we need to understand what are “things” here?

We are talking about physical things. It could be anything objects, appliances, vehicles, buildings, Animals, people, anything on planet.

 

Secondly, these things have to be transformed into smartThing. So, what are SmartThings?

 

As you can see in the depiction below, physical objects become smart objects when they get associated with sensors and an IP.

 

iot-1

 

Lastly, how these smart objects communicate over Internet?

 

Once physical objects have sensors and an associated IP, these objects get the ability to send and receive data. This data can be transferred using internet and can also be stored on cloud. Moreover, this data can be consumed by various Applications, mostly Mobile Applications.

 

iot_2

 

This means Your App on Mobile device can communicate to a physical object like your freeze or your keys or your light switch in your house. It can receive information and send commands to perform actions.

 

This whole ecosystem is termed as Internet of Things.

 

So, how does it impact our life? In fact, this can impact our lives beyond our imagination.

 

In future, Google will not only remain a search engines for web content but you will also be able to perform operations like this.

iot-3

 

Or

 

Your fridge will send you an alert on your Mobile phone to bring milk packets as soon as you reach a super market.

iot-4

 

By now, you would have observed that IOT is about connecting our physical world to Internet. It’s predicted that by 2020 there will be 50 Billion smart Objects. And, every human being will be surrounded by 3000 to 5000 smart Objects.

 

iot-5

 

Does it trigger any thought, how are you going to test applications built for Internet of Things? We will soon be discussing that in our upcoming post.