memory leak analysis in android games

Post on 12-Apr-2017

28 Views

Category:

Engineering

2 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Memory Leak Analysisin

Android Games

Heghine HakobyanSoftware Engineer

Why we need memory analysis?

● Low FPS

● Frequent Freezes

● Out of Memories

Why we need memory analysis?

Improved Performance

Happy Users

No Memory Leaks

Problems to Consider

● A lot of consequent GC calls

- because of temporary allocations

● Not enough memory

- for permanent objects

Garbage Collector

GC_CONCURENT freed 24K, 18% free 1572K/19207K, paused 1ms+4ms

How GC works?

exampleA

exampleB......

exampleA is dominator of exampleB

Dominator Tree in GC

exampleA

exampleB......

r

...

a

...

......

Dominator Tree in GC

exampleA

exampleB......

r

...

a

...

......

Allocation Tracker

Shows where and what type of objects are being allocated at current time

Going Deeper: Heap Dump

Gives huge amount of statistical information about your game’s current heap state

Use it withEclipse Memory Analyzer (MAT)

Heap Dump Components

DominatorTree

HistogramView

Heap Dump

Heap Dump Example

Example Game

Obstacle

Target

Soldiers

Vikings Battle

The Problem

● A lot of soldiers (~300)

● Moving from start position to target

● Using A* path finding algorithm

Low Performance

Soldier Statistics

Type Bowman

Shallow Heap 312 b

Retained Heap ~22 kb

Animation Component

Retained Heap~20 kb

Solution: Object Pooling

Bowman b = getSoldierFromPool();b.initialize();

Use object as you need

b.reset();

Heap

Thank You!!!

Remember!Memory Analysis are

IMPORTANT!

Questions?

top related