memorystatus_control cannot set priority on iOS 9 and 10

Questions and Answers about all things *OS (macOS, iOS, tvOS, watchOS)

memorystatus_control cannot set priority on iOS 9 and 10

Postby Wingzero » Fri Sep 29, 2017 4:01 am

so I read the article about memorystatus_control.

I tried to use it to set memory limit, it works. However if I tried to set the priority, it seems on iOS 9 & 10, priority is always 0.

Here's my code:
Code: Select all
    int pid = (int)getpid();
    // call memorystatus_control
    memorystatus_memlimit_properties_t memlimit;
    memlimit.memlimit_active = 120;
    memlimit.memlimit_inactive = 120;

    DDLog(@"setting memory limit for Worker pid:%d", pid);
    int rc = memorystatus_control (MEMORYSTATUS_CMD_SET_MEMLIMIT_PROPERTIES,
                                   pid,    // pid
                                   0,    // flags
                                   &memlimit, // buffer
                                   sizeof(memlimit)); // buffersize

    DDLog(@"DONE: setting memory limit for MIWorker pid:%d, rc:%d", pid, rc);

    // call memorystatus_control
    memorystatus_priority_properties_t priority;
    priority.priority = 15;
    priority.user_data = 15;

    rc = memorystatus_control (MEMORYSTATUS_CMD_SET_PRIORITY_PROPERTIES,
                                   pid,    // pid
                                   0,    // flags
                                   &priority, // buffer
                                   sizeof(priority)); // buffersize

    DDLog(@"DONE: setting priority for Worker pid:%d, rc:%d", pid, rc);


using "mtool" always give me:
Code: Select all
iOS-76:~ root# mtool|grep 49158
PID: 49158   Priority: 0   User Data: f   Limit:120   State:0x18 Tracked,IdleExit


I checked memorystatus_control returns 0, so the command should success, and limit is 120, user data is 0xf (15), which are both correct. Only priority is always 0.

What's going on here?
Wingzero
 
Posts: 34
Joined: Thu Jul 27, 2017 2:35 am

Re: memorystatus_control cannot set priority on iOS 9 and 10

Postby morpheus » Sun Oct 01, 2017 9:11 pm

Maybe it's due to my article way back when, but - you now need an entitlements for memorystatus/jetsam


http://newosxbook.com/ent.jl?ent=com.ap ... sVer=iOS11
and
http://newosxbook.com/ent.jl?ent=com.ap ... sVer=iOS11 (likely the one that stumps you)
as well as

http://newosxbook.com/ent.jl?ent=com.ap ... sVer=iOS11


Jtool --sign --inplace --ent ....xml should fix that.
morpheus
Site Admin
 
Posts: 532
Joined: Thu Apr 11, 2013 6:24 pm

Re: memorystatus_control cannot set priority on iOS 9 and 10

Postby Wingzero » Sun Oct 08, 2017 1:31 am

hi morpheus, mind to give a hint how do I search and apply the entitlement files for my daemon process? Kind of blind about this. Vol III is still on the way so I don't know if they are in the book.

The link you gave me is kind of cross reference to me, not listing the entitlements details I supposed. So how do we use the database anyway?

What you said "you now need an entitlements for memorystatus/jetsam" but it makes me confused. Jetsam is the OOM killer.

I will walk through jtool doc soon. Might be newbie questions.. Thanks!
Wingzero
 
Posts: 34
Joined: Thu Jul 27, 2017 2:35 am


Return to Questions and Answers

Who is online

Users browsing this forum: No registered users and 2 guests