facebook/FBMemoryProfiler

Name: FBMemoryProfiler

Owner: Facebook

Description: iOS tool that helps with profiling iOS Memory usage.

Created: 2016-04-07 18:24:13.0

Updated: 2018-01-13 15:01:25.0

Pushed: 2017-10-27 00:54:18.0

Homepage: null

Size: 1829

Language: Objective-C

GitHub Committers

UserMost Recent Commit# Commits
Dave Lee2016-08-29 14:37:14.03
Steffen Matthischke2016-04-18 21:12:58.01
Björn Dahlgren2016-04-15 07:45:59.01
Michael Berg2016-04-23 04:13:25.01
Grzegorz Pstrucha2016-10-17 16:56:34.013
Minyoung Kim2016-08-29 14:14:10.01
Pei Hsuan Chang2016-04-29 05:25:31.01
Adel MEZARA2016-04-19 12:45:49.02

Other Committers

UserEmailMost Recent Commit# Commits
armingliarmingli@tencent.com2016-10-14 09:49:25.01
Dave Leekastiglione@fb.com2016-04-13 21:24:42.01
Mihai Babuscamihai.babusca@woowteam.com2016-07-21 13:29:56.01
phchangphchang@yahoo-inc.com2016-05-01 05:15:01.01
Yen-Chia Linyen-chia.lin@runtastic.com2016-04-28 12:26:33.01

README

FBMemoryProfiler

Carthage compatible CocoaPods

An iOS library providing developer tools for browsing objects in memory over time, using FBAllocationTracker and FBRetainCycleDetector.

About

This library shows how FBAllocationTracker and FBRetainCycleDetector can cooperate together, and how they can be used in real app.

It uses FBAllocationTracker to gather information about the objects. It supports generations and retain cycle detection.

Here is a small demo (project is available in Example directory)

Installation
Carthage

To your Cartfile add:

github "facebook/FBMemoryProfiler"

FBMemoryProfiler is built out from non-debug builds, so when you want to test it, use

carthage update --configuration Debug
CocoaPods

To your podspec add:

pod 'FBMemoryProfiler'

You'll be able to use FBMemoryProfiler fully only in Debug builds. This is controlled by compilation flag that can be provided to the build to make it work in other configurations.

Usage

To start using FBMemoryProfiler you'll first need to enable FBAllocationTracker.

ort <FBAllocationTracker/FBAllocationTrackerManager.h>

main(int argc, char * argv[]) {
FBAllocationTrackerManager sharedManager] startTrackingAllocations];
FBAllocationTrackerManager sharedManager] enableGenerations];
utoreleasepool {
  return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));


To enable memory profiler:

ort <FBMemoryProfiler/FBMemoryProfiler.h>

moryProfiler *memoryProfiler = [FBMemoryProfiler new];
oryProfiler enable];

tore memory profiler somewhere to extend it's lifetime
oryProfiler = memoryProfiler;

FBMemoryProfiler will show up as a button on the screen. Once tapped, it will open memory profiler in full size mode.

We can also define plugins (check below) and filters for retain cycle detector, that we pass to configuration.

oryProfiler = [[FBMemoryProfiler alloc] initWithPlugins:@[[IncredibleCacheCleaningPlugin new],
                                                          [AwesomeLoggerPlugin new]]
                       retainCycleDetectorConfiguration:someConfigurationWithCustomFilters];
moryProfiler enable];
Plugins

Plugins are objects that conform to FBMemoryProfilerPluggable protocol. Example usage: custom cache cleaners, loggers that log data to server.

Contributing

See the CONTRIBUTING file for how to help out.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.