iOS Question Memory monitoring

JackKirk

Well-Known Member
Licensed User
Longtime User
In this post:

https://www.b4x.com/android/forum/threads/app-not-starting-on-iphone-4s-and-6.68047/#post-433612

Erel posted this code:
B4X:
Sub UsedMemory As Long
   Dim no As NativeObject = Me
   Return no.RunMethod("usedMemory", Null).AsNumber
End Sub

#if OBJC
#import "mach/mach.h"
- (vm_size_t) usedMemory {
  struct task_basic_info info;
  mach_msg_type_number_t size = sizeof(info);
  kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
  return (kerr == KERN_SUCCESS) ? info.resident_size : 0; // size in bytes
}

#end if

to "find the used memory size".

2 questions:
  • I assume this means the total memory used by the app.
  • Is there any code that can return the maximum memory the app can use?
Thanks...
 

JackKirk

Well-Known Member
Licensed User
Longtime User
What do you need it for? Did you encounter any error?
Yes - I'm having silent crashes on both debug and release versions of an app I'm porting from B4A

Using the above code I've been able to work out what I'm doing wrong - I've nearly got it fixed.

Interesting the app is falling over at about 648MB on my iPhone 5 - the table you point to in your post suggests about 645MB - so good confirmation.

I suspect I have the same problem on the B4A version - I just haven't stress tested it as extensively yet.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…