3

My app is downloading base64 encoded content, in most cases PDF documents. It is transferred via web service and wrapped up in SOAP. The documents can reach sizes of up to 100 MB.

To store these files locally, I need to extract them from the SOAP envelop, decode the base64 string and write to storage.

Problem is, that a document of about 1 MB increases the temporary memory usage by 20-30 MB. When tracking allocations in Instruments, I can see those peaks. This isn't so much a problem. But a document of 60 MB increases memory by around 800 MB, and that's definitely too much for iOS devices.

I'm trying to change the app so that the peaks can be prevented or at least lowered. Alas, I don't exactly know which lines of code are responsible.

Is there a possibility to step through the code and also view current allocations or memory usage at the same time?

I know stepping through doesn't work when app is executed by Instruments. So, are there any other options?

Here is how Instruments looks like: enter image description here

Thanks in advance!

4
  • Please try to use the Instruments in the Xcode . Just click command+i in the keyboard Commented Apr 3, 2013 at 6:54
  • As I wrote, I already did that and could see the peaks. If I didn't find how to track down the responsible code line - please tell me. Commented Apr 3, 2013 at 8:48
  • go to your project and in the project navigator you can find the issue navigator,Breakpoint navigator ... . click on Breakpoint navigator and at the bottom find the + button. Click on it and add the exception breakpoint Commented Apr 3, 2013 at 10:27
  • I'm sorry, but I don't understand what an Exception breakpoint could help me in that situation. What exception anyway? Commented Apr 3, 2013 at 11:00

2 Answers 2

4

To track allocations in a certain period of time, what I normally do is mark the start and end points in the timeline using the inspection range buttons:

Instruments Inspection Range Buttons

That filters the allocations list and just shows you allocations done in that period of time. I normally sort by the "# living" column in order to find out what types of objects were allocated during that period. With the extended detail panel open, I select which ever suspicious object and click on the arrow by the class name:

Instruments Allocations

That displays the list of instances of that type of object. Selecting one, will show you, in the extended panel, the stack trace. That information can already hint you how these objects are being allocated.

In addition, if you select a particular instance using the arrow by the class name again, you see that object's history in terms of memory events. Also, if you double click on a stack trace call it will show you the code where that memory event is happening:

Object Stack Trace

With this information you should be able to know what is going on. If the object you selected is not the culprit, you can continue inspecting the rest. In order to navigate back to the object list you can click on "Object Summary" in the navigation bar:

Allocation Instruments Navigation Bar

Good hunting.

Sign up to request clarification or add additional context in comments.

Comments

1

check out this link that helps you understands heap allocations. It will help you track the allocations.Hope this helps. You can also use activity monitor which lets you track the memory consumed by an app at any particular time when using the app.

you can also check the code that is allocating memory , please find attached screen shot.enter image description here

1 Comment

Alas, it doesn't help me finding these temporary peaks. (I just added an image to my question.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.