Detect recently loaded memory


Alex Zavatone
 

I have a situation in our iOS app where we visit one screen, maybe click in a field and around that time, memory used jumps.

Now, it only jumps about 5 MB when running the app normally and navigating there manually, but when using the KIF testing framework, the memory used jumps 40 MB.

This would merely be annoying, but I have had to split up our UI testing into 4 sequentially executed test targets because this memory ends up never being released until the app quits and it is common for the tests to freeze or crash the whole Mac.

I have checked the dynamically loaded libs to see if unneeded libs are being loaded, but it seems to be that it’s something in our code but that every object is much larger. Does anyone know if there is a way in the heap tool or a similar tool to check only recently loaded objects when parsing a memory graph?

Thanks in advance.
Alex Zavatone


 



On Jun 26, 2019, at 11:23 AM, Alex Zavatone via Groups.Io <zav@...> wrote:

I have a situation in our iOS app where we visit one screen, maybe click in a field and around that time, memory used jumps.

“Memory used” has many different meanings in a modern OS. Do you specifically mean heap space? Or RPRVT, which is pretty similar?

If it’s heap space, then Instruments should be able to help. Try the Leaks instrument first.

—Jens


Alex Zavatone
 

> Use the leaks instrument first

And that’s the problem.  How do you run a leaks or allocations test in Instruments while executing your tests without causing either Instruments to stop recording or tests to stop running?

I am suspecting that there is some “instantly transfer the debugger session to the Instruments and immediately start recording” option that I don’t know about.

Starting my tests, then clicking on the memory the memory meter and then on Profile in Instruments is OK, but still clunky.

Thanks, J


On Jun 26, 2019, at 1:32 PM, Jens Alfke <jens@...> wrote:



On Jun 26, 2019, at 11:23 AM, Alex Zavatone via Groups.Io <zav@...> wrote:

I have a situation in our iOS app where we visit one screen, maybe click in a field and around that time, memory used jumps.

“Memory used” has many different meanings in a modern OS. Do you specifically mean heap space? Or RPRVT, which is pretty similar?

If it’s heap space, then Instruments should be able to help. Try the Leaks instrument first.

—Jens


 



On Jun 27, 2019, at 6:54 AM, Alex Zavatone via Groups.Io <zav@...> wrote:

And that’s the problem.  How do you run a leaks or allocations test in Instruments while executing your tests without causing either Instruments to stop recording or tests to stop running?

Oh, I hadn't grasped that this only happens during tests!

There is a `leaks` command I've used in the past, but I don't know if it still exists, or if it works on iOS Simulator processes…

—Jens


Alex Zavatone
 

So, the problem is that I CAN add profiling of the test targets to the specific test scheme, but when I then right click on the tests and select Profile or from the proper menu, Profile without Building, the test runs, opens Instruments, and logs for a while and then stops.  When I attempt to do the same option again, The build completes, Instruments opens, but no tests run.

So, with leaks, I was running leaks and heap 2 weeks ago and this is where I am now.

The reason I am going through all this is that KIF loads all the dylibs from the Simulator and KIF is what we use to drive our tests.  Certain activities that allocate 5 MB of memory when run manually, take 40 in the KIF driven tests.  

This would be a mere interesting artifact, except that after each test file completes, memory isn’t released.  KIF tests exacerbate our memory suckyness.  

Now, I would expect a rise in the base memory used with the loading of each dylib, but it appears as each subsequent allocation takes more memory and since the memory is not released until the running app quits, after 20+ minutes, the fit hits the shan and the logged in Mac user either crashes out to the login screen or the Mac freezes.  Hence the suckage.

This is why I have been asking for clues to check out the size of instantiated objects.  I’m trying to see if KIF or UITests add a metric crapload of memory to each instantiated object.  I do have this now, but haven’t checked.  

What does blow me away is that the app takes MUCH more memory when running under KIF UI testing and with at least 8x the amount of memory sticking in memory when being run this way, I’d like to have a clue as to why.

Now the Royal Pain In The Ass™ is that when run through Instruments and when leaks are found, I have enabled all I need to see the stack trace, but sweet mother of crap.  The area that leaks doesn’t look like it should be leaking.  I can’t tell why or what’s wrong.  

Crap.

In the past, I’ve dealt with retain loops and strong references to self and so on, but these calls are just normal looking.  Leaks and the tools can tell me that something’s leaking, but for the love of puppies, I can’t see anything that looks out of sorts.

That’s the summary.  I have memory usage charts and stack traces and the stuff that indicates to leaks that it’s leaking doesn’t look like it’s indicative of causing said aforementioned leaky bits.

Thanks.
AZ


On Jun 27, 2019, at 10:55 AM, Jens Alfke <jens@...> wrote:



On Jun 27, 2019, at 6:54 AM, Alex Zavatone via Groups.Io <zav@...> wrote:

And that’s the problem.  How do you run a leaks or allocations test in Instruments while executing your tests without causing either Instruments to stop recording or tests to stop running?

Oh, I hadn't grasped that this only happens during tests!

There is a `leaks` command I've used in the past, but I don't know if it still exists, or if it works on iOS Simulator processes…

—Jens