yashsingh1/xdaforums huggingface dataset:
[Sony Cross-Device General] ondrejvaroscak:
First thing - what we have found out and coded - is a workaround, not a solution. The solution must come from Xposed developer. Or fork.

There are off-trades, mainly higher memory consumption. Simply as we allowed more files to be left open, more memory is used to map these files.

Also, it is clear that Xposed processes files differently after Dalvik and cache have been wiped. So that's why first boot after wipe is stable. Seemingly while compiling and executing apps for first time, process treats files properly. With subsequent boot while it process cached executables, it creates problems.

That also explains instability on both kernel modified or script modified system. It modifies same parameter but just using different method.

One thing is in my head, devs and system guys can look at it: changing limits for zygote also changes limits for all child processes. You can see when you log from adb and ulimit -nS you get 1024. If you enter same from Android terminal you get value you set in script. That's because adb shell is not fork of zygote but terminal is. Maybe it would help to lower the numbers again when system is fully booted and do for all pids setting limit back to 1024..

At this moment I have no better proposal. also I am no developer, I am more oriented to the underlying system level...
[Sony Cross-Device General] ondrejvaroscak:
No worries here, I try to explain what's behind the curtains.
[Sony Cross-Device General] ogunja:
I can not understand, after installing recovery via the script just got bootloop ..

Simple process but I'm not getting.

I did as instructed below>

Instruction:

Just flash Both Zip-Files via CWM or TWRP

1. XZDR_Inid-Enabler

2. flimit_flashable_2048 or flimit_flashable_4096

3. Reboot (the Necessary wipes)
[Sony Cross-Device General] moonryder:
[MENTION=6351145]ondrejvaroscak[/MENTION]

i don´t find XZDR.prop, where to find?

only found xposed.prop in /system :confused:
[Sony Cross-Device General] ondrejvaroscak:
It is in your Sd card or in /cache if you have no sd card inserted
[Sony Cross-Device General] moonryder:
no way, there is no such file on extSD or intSD ...

(flashed firmware, rebooted, flashed both flim files and xposed.zip, rebooted and installed xposed framework) :confused:
[Sony Cross-Device General] McBane87:
Do you have a sdcard in your phone?

Is there a file /storage/sdcard1/XZDualRecovery/XZDR.prop?

What is XZDualRecovery.log (same directory) saying?
[Sony Cross-Device General] moonryder:
Oh Mann, sorry, hab den Ordner auf der externen total übersehen - Tomaten auf den trüben Augen ...

Hab gesehen dass im script beide Werte bereits gesetzt sind.

Danke vielmals für die Modifkation :good:

in english:

All is good, found it, thx
[Sony Cross-Device General] ogunja:
Yes to both, as mandated by the tutorial.

It seems I am the only one to have loop kkk
[Sony Cross-Device General] McBane87:
In XZDualRecovery.log it should somewhere saying, that 01_flimit was loaded/executed.

Is it?
[Sony Cross-Device General] RJASSI21:
Can confirm working on xz2 d6503 and xz2tab sgp511 .690 thanks works perfect no issues
[Sony Cross-Device General] ogunja:
My device is being updated after wipe cache and dalvik, right now I'm with debloated 256 apps and must give wipes cache and dalvik every time I restart the machine.
[Sony Cross-Device General] McBane87:
Yes I get it.

But to help, I need you to answer the questions.

I'm trying to delimit the problem.
[Sony Cross-Device General] chesterr:
You guys managed to get Amplify to work?
[Sony Cross-Device General] eng.a.s:
I used the flashable files it work's great.. Thank you so much

Sent from my D6503
[Sony Cross-Device General] redincali:
Just wanted to say great find [MENTION=6351145]ondrejvaroscak[/MENTION] and to [MENTION=4712883]McBane87[/MENTION] for the extra flashables. I had wondered if what was being done to the kernel could be done thru a script, just hadn't had time to look into it (new job is taking all my time). Just wondering though, if we set it back to the lower default 1024 after booting, will it fix the issues some are having with random reboots or apps not working correctly?

Maybe we can have another script run at the end of booting(if possible), or use an app that runs scripts on startup, or maybe even a module that resets it back to default([MENTION=3989065]serajr[/MENTION]). Just a thought. Also I haven't tried this work around yet but I am following the thread (which has grown alot in 9hrs). Keep up the good work Sirs!

~ via Xperia Z3, XDA App
[Sony Cross-Device General] leso60:
installation was successful via recovery in D5803 LB no bootloop, but at each reboot i get the message "updating android" :confused:
[Sony Cross-Device General] ondrejvaroscak:
Nope, Amplify loads but seems to do nothing at all.
[Sony Cross-Device General] ondrejvaroscak:
I have an idea, see my post http://xdaforums.com/showpost.php?p=60283758&postcount=74
[Sony Cross-Device General] ogunja:
When you change the last two lines that are on the sdcard to true and flash file via TWRP or philz get bootlooping always
[Sony Cross-Device General] hispanico957:
Yes procedure confirmed by many my friends :highfive:

Hispanico
[Sony Cross-Device General] ondrejvaroscak:
Try manual installation then like I have described in OP...
[Sony Cross-Device General] ondrejvaroscak:
Crafting new version

Hi folks, I am just boiling new version of the script which will hopefully work better. It will again wait for zygote to run, change of limits to proven value of 2048, then wait for device to finish booting process and set zygote and subsequent processes back to 1024.

This should solve problems with applications or system being killed by exhausting of resources. I hope to have it running by morning CET.

I was thinking also about cooking flashable version, but I am leaving this honor to [MENTION=4712883]McBane87[/MENTION]
[Sony Cross-Device General] hispanico957:
BIG THANK AGAIN.... but foe us that we have already flash old script or manual modified it.... i think and hope that new flash of script can be overwrite old settings ... :cowboy:

Hispanico
[Sony Cross-Device General] ondrejvaroscak:
Yes, i think we will manage...
[Sony Cross-Device General] guap:
currently not working on D5503 lollipop stock. Installed flashable version, all ok, installed xposed, all ok, installed xposed apk -> bootloop
[Sony Cross-Device General] ilos:
My Z1 boot with 4096 value so i've looked for an automatic return to 1024 and now i'm using third party app (https://play.google.com/store/apps/details?id=os.tools.scriptmanager&hl=fr) to run modified 01_flimit (put on my SDCARD) with value 1024 to run at boot (ie when launcher appear not during boot sequence) and it's working great :)
[Sony Cross-Device General] ondrejvaroscak:
Cool, can you post your modified script?
[Sony Cross-Device General] ilos:
it's simply your 01_flimit script with value 1024 4096 (in place of 4096 4096) nothing more :) when i said modified it's only about value sorry ;)

to be more explicit : i left all files installed like in OP post, i use another 01_flimit file put on my SDCARD , i've changed value inside and used script manager to load this file on boot ( so after your workaround during the boot sequence) and voila :D
[Sony Cross-Device General] ondrejvaroscak:
That has one glitch... it only changes limits for original zygote process and all child processes initiated AFTER that change. So of course it will be applied on newly run apps, however it will leave apps that are already running, with high limits, unless these apps are killed and restarted.

There is a script, that you can run instead of that you modified. This script gets list of all running processes as variable, and change their respective limits back to 1024 4096

#!/system/bin/sh
#
#version 1.0
#all processes filelimits customization
#Created by Ondrej Varoscak (ondrejvaroscak @ xda-developers)
#Copyleft
#
#flimit executable source code from http://lzone.de/cheat-sheet/ulimit
#no copyright statement - reused and redistributed in good faith
#
PIDS=$(ps -p | awk '{print $2}')

for i in $PIDS
do
/system/bin/flimit $PIDS 1024 4096
done
exit 0

you NEED to change the /system/bin/flimit to /data/fllimit/flimit if you you my original instructions, or leave as /system/bin/flimit if you use flashable
[Sony Cross-Device General] ilos:
ok i trying now and keep you posted

EDIT : it seems to work, but how can i check another PID than zygote ?

EDIT 2 : ok i've check another PID and it's not working check screen for output when i try to run the new script
[Sony Cross-Device General] McBane87:
So in those Screenshots you already reverted the Workaround back to normal?

If you would like to try it again, then:

After flashing both ZIP-Files, please check if following files are there:

/system/bin/flimit
/system/etc/init.d/01_flimit

And also check if those two lines are in XZDR.prop are now "true":

dr.initd.active=true
dr.keep.byeselinux=true
[Sony Cross-Device General] hispanico957:
...ondrejvaroscak i think that you test this new script and respect the old, you see be improvements ??

Thank

Hispa
[Sony Cross-Device General] ondrejvaroscak:
SCHOOL BUG FOUND

new script here

#!/system/bin/sh
#
#version 1.0
#all processes filelimits customization
#Created by Ondrej Varoscak (ondrejvaroscak @ xda-developers)
#Copyleft
#
#flimit executable source code from http://lzone.de/cheat-sheet/ulimit
#no copyright statement - reused and redistributed in good faith
#
PIDS=$(ps -p | awk '{print $2}')
for i in ${PIDS}
do
/system/bin/flimit $i 1024 4096
done
exit 0

you NEED to change the /system/bin/flimit to /data/fllimit/flimit if you you my original instructions, or leave as /system/bin/flimit if you use flashable[/QUOTE]

FORGET guys about the script for a while, need to find way around:

However, there is another glitch, I was getting for granted that all processes should have 1024/4096 by default, but there are processes in android, that (beiing NOT child of zygote) have limits even 8192/8192 so setting them 1024 can cause major problems...

I need to find different way how to get changed only zygote and zygote child, nothing else.
[Sony Cross-Device General] McBane87:
So this is the Script you can call after System was booted?

In order to revert changes made by Init-Script?
[Sony Cross-Device General] ondrejvaroscak:
yes, need to check system booted state, but if you run it in script manager app than no need for boot state check
[Sony Cross-Device General] McBane87:
So if you wan't to use as second init-script you maybe can use one of those checks:

root@D5503:/ # getprop sys.boot_completed
getprop sys.boot_completed
1

root@D5503:/ # getprop init.svc.bootanim
getprop init.svc.bootanim
stopped

#!/system/bin/sh
#
#version 1.0
#all processes filelimits customization
#Created by Ondrej Varoscak (ondrejvaroscak @ xda-developers)
#Copyleft
#
#flimit executable source code from http://lzone.de/cheat-sheet/ulimit
#no copyright statement - reused and redistributed in good faith
#

while [[ $(getprop sys.boot_completed) -eq 0 ]]; do
sleep 1
done

PIDS=$(ps -p | awk '{print $2}')
for i in ${PIDS}
do
/system/bin/flimit $i 1024 4096
done
exit 0

Didn't checked if it is working....
[Sony Cross-Device General] bobet96:
Restoring my backup. My Z2 became unstable (rebooting even if I'm not doing anything). I think I'll wait for a working Xposed.
[Sony Cross-Device General] ondrejvaroscak:
Sorry for that, but without additional info like logs etc we cant investigate, correct and do anything. So your post has no help to others. Sorry.
[Sony Cross-Device General] ondrejvaroscak:
Using that in my test... thank you anyway
[Sony Cross-Device General] ondrejvaroscak:
There is a bug, command for getting list of PIDs should be ps | awk '{print $1}' and not ps -p | awk '{print $2}'

However, there is another glitch, I was getting for granted that all processes should have 1024/4096 by default, but there are processes in android, that (beiing NOT child of zygote) have limits even 8192/8192 so setting them 1024 can cause major problems...

I need to find different way how to get changed only zygote and zygote child, nothing else.
[Sony Cross-Device General] ondrejvaroscak:
Found small problem, need more time to get way around it:

However, there is another glitch, I was getting for granted that all processes should have 1024/4096 by default, but there are processes in android, that (beiing NOT child of zygote) have limits even 8192/8192 so setting them 1024 can cause major problems...

I need to find different way how to get changed only zygote and zygote child, nothing else.
[Sony Cross-Device General] ondrejvaroscak:
Found error, PIDS=$(ps -p | awk '{print $2}') should be PIDS=$(ps | awk '{print $1}')

However, there is another glitch, I was getting for granted that all processes should have 1024/4096 by default, but there are processes in android, that (beiing NOT child of zygote) have limits even 8192/8192 so setting them 1024 can cause major problems...

I need to find different way how to get changed only zygote and zygote child, nothing else.
[Sony Cross-Device General] McBane87:
Maybe this way?

Assuming all child processes have PPID of zygote:

ps | grep $(pidof zygote)

Or a little bit more safely with space before and after:

ps | grep " $(pidof zygote) "

Best way:

pgrep -P $(pidof zygote)
[Sony Cross-Device General] mionica:
for pid in $(ps|awk '{print $1}')
do
/system/xbin/flimit $pid | grep 'soft=2048; hard=4096' 2>&1 > /dev/null \
&& /system/xbin/flimit $pid 1024 4096 2>&1 > /dev/null
done

ta-da!

note, you might want to replace /system/xbin with wherever you actually put the thing in your system; also note, the above has a chance of changing stuff it shouldn't - i.e. if any process has a 2048/4096 limit by default, it will get to 1024 4096 for no damn reason.

to improve this, I'd suggest a more awkward limit for zygote by default, such as 2000 or 1733 or whatever; that'll greatly decrease the chances of finding the wrong processes to mess with

EDIT: I switched to 1535 4095, and it seems to work just fine.

EDIT2: It didn't, for some (with plenty of apks); changed to 2047 4095 - no complaints yet :D.
[Sony Cross-Device General] bobet96:
You should put a warning/disclaimer about the risks so people would know what they're going into.:cyclops:
[Sony Cross-Device General] mionica:
Think of this as troll bait. I'm personally quite happy to see clueless people getting into trouble because they didn't understand that this is XDA, not the public space - that is, it's not necessarily for everyone. Particularly not for people who can't find the time to read a freakin' forum.

And as somebody rightly pointed out, yes I did start as a troll myself. Now, if I hadn't hurt myself a good few times, I'd have never learned anything; I'd go as far as to say that if I hadn't done a good few boo-boo-s, I'd still be a troll. I'm not being cruel - it's just that IMO hurting yourself is an excellent pretext to learn something you didn't know before :D

Now, that said. Disclaimers ffs... that's just going over the top. We're developers, engineers and enthusiasts here. Not lawyers.
[Sony Cross-Device General] McBane87:
I get what you want to do. Just only change flimit on pid which have 2048,

but if I don'T get it wrong your script isn't only changing values of 2048 because your grep doesn't affects the followed command.

As far as I know "&&" only means: execute following command if the command before was successfull.

Edit:

Ah, forget it.

If grep doesn't finds 2048, then it wasn't sucessful and next won't be executed. SO you are right^^
[Sony Cross-Device General] mionica:
in practical terms, && means, execute following command if the last process in the previous pipe was successful. That's grep; flimit - wrongly returns error in all cases, even when it succeeds (according to the .c). it's quite easy to understand if you think the last command in a pipe will usually be the last to kick the bucket if all run to completion - so it'll be the most recent who set the return errcode

Anyway, my install .zip's are up, and working :D
[Sony Cross-Device General] McBane87:
Yes I realized that a few seconds later by myself^^
[Sony Cross-Device General] HypoTurtle:
$1 is busybox ps and $2 is toolbox ps

Which zygotePID should this be applied to? I have three (zygote,zygote64 and xposed_zygote) so the command:

/data/flimit/flimit $ZPID 2048 4098
becomes
/data/flimit/flimit ZPID1 ZPID2 ZPID3 2048 4098

as your using $(pgrep zygote), McBanes $(pidof zygote) locates just zygote.
[Sony Cross-Device General] _mysiak_:
1535 resulted in bootloop in my case (401 packages were being optimized after xposed installation), changed it to 2001 and system booted fine.
[Sony Cross-Device General] mionica:
@McBane87, re (deleted :p) /cache comment

I'm not touching /cache at all. I attempt to mod XZDR.prop at /data/data/com.camber.ndrutils/cache, /external_sd/XZDualRecovery and /storage/sdcard1/XZDualRecovery. There's no need to wipe /cache, ever - not even the xposed installer does that - because android seems to detect somthing changed and recompiles everything anyway.

Now, I did add a "Be SURE to wipe dalvik cache!!!" to my uninstaller script, but that's a another thing.

Have a look at the .zip's :)
[Sony Cross-Device General] McBane87:
Maybe it is different on Xperia Models?

On my Z1 COmpact I have only zygote:

root@D5503:/ # ps | grep zygote
ps | grep zygote
root 607 1 1502896 46388 ffffffff b6f9c02c S zygote
[Sony Cross-Device General] mionica:
Good man; just be sure to change in both scripts under etc/init.d (the grep should read grep 'soft=2001; hard=4095' in your case)

Fixed the .zip attached to the initial post; now it sets temp limits to 2047/4095.
[Sony Cross-Device General] McBane87:
Yeah sorry I should wait and otherthought before I post. I just read cache and my fingers where already hitting the keyboard^^ That's why I deleted it already :)
[Sony Cross-Device General] bobet96:
Stop being a snoot. You were once a troll. :angel:
[Sony Cross-Device General] HypoTurtle:
I'm not on an Xperia - just a 64-bit device which is why there's two, and running the 'unofficial' 64-bit Xposed explains the other (I guess)

# ps | grep zygote
root 262 1 2098188 68260 ffffffff 999fe324 S zygote64
root 263 1 1515108 52820 ffffffff f74695fc S zygote
root 769 263 37908 2368 0010b188 f7440eac S xposed_zygote_service

Probably will need a 64bit/zygote64 check if you want to make it more universal.
[Sony Cross-Device General] :
This sounds awesome but when you said this could work lots of devices, has anyone tried this on a Samsung or is it not compatible?
[Sony Cross-Device General] kientrongtran:
I flashed the two zips (4096), there's no more bootloop but under Framework, app_process and xposedbridge.jar are active but the error is still the latest version of xposed is currently not active and modules doesn't load.

I'm on Z ultra, stock lollipop, twrp

edit: uninstall xposed apk then reinstall, grant root, reboot, the error is gone. Thanks for the incredible job!:D
[Sony Cross-Device General] McBane87:
If the binary flimit is executable on your device and you find a way to execute init.d-Scripts on your device, then maybe.

But are you sure the "too many files" error is also the Problem with Xposed on Samsung?

Because this workaround is just for this error only.
[Sony Cross-Device General] :
I honestly have no idea. I am just dying to get Xposed or an unlocked bootloader. But thanks, just curious
[Sony Cross-Device General] hispanico957:
...dear McBane87 when you think to post new script ? :angel:

You will prepare always two files like flimit_flashable_4096.zip and flimit_flashable_2048.zip or at this pint only one ?

Hispa
[Sony Cross-Device General] ondrejvaroscak:
Agree, this is a developers space. So while we are happy to provide as much help as needed, this is development site. If you dont understand the risk of using development software, stick with Stock ROM. I am getting fed with people, who just want some cool bells and whistles while having no clue what they are doing.
[Sony Cross-Device General] ondrejvaroscak:
great, so far I am on this. I am running test version with some logging and echoing to flimit.log, script seem to exit prematurely while changing some child pid...

!/system/bin/sh
#
#version 2.0
#zygote filelimits customization
function zygote_wait {
ZPID=$(pgrep zygote)

if [ -n "$ZPID" ]; then
/system/bin/flimit $ZPID 2048 4096
else
sleep 0.1
zygote_wait
fi
}

function boot_wait {
while [ ""`getprop dev.bootcomplete` != "1" ]
do
sleep 0.1
done
}

function limit_restore {
ZPID=$(pgrep zygote)
/system/bin/flimit $ZPID
/system/bin/flimit $ZPID 1024 4096

PIDS=$(pgrep -P $(pidof zygote))
for i in ${PIDS}
do
/system/bin/flimit $i 1024 4096
done
}

zygote_wait
boot_wait
limit_restore

exit 0

version with loging to /sdcard/flimit.log:

#!/system/bin/sh
#
#version 2.0
#zygote filelimits customization
#Created by Ondrej Varoscak (ondrejvaroscak @ xda-developers)
#Copyleft
#
#flimit executable source code from http://lzone.de/cheat-sheet/ulimit
#no copyright statement - reused and redistributed in good faith

function zygote_wait {
echo "$(date) checking zygote" >>/data/media/0/flimit.log
ZPID=$(pgrep zygote)

if [ -n "$ZPID" ]; then
echo "$(date) zygote found at $ZPID" >>/data/media/0/flimit.log
/system/bin/flimit $ZPID 2048 4096 >>/data/media/0/flimit.log
echo "$(date) leaving zygote_wait" >>/data/media/0/flimit.log
else
echo "$(date) waiting for zygote" >>/data/media/0/flimit.log
sleep 0.1
zygote_wait
fi
}

function boot_wait {
while [ ""`getprop dev.bootcomplete` != "1" ]
do
echo "$(date) waiting for boot" >>/data/media/0/flimit.log
sleep 0.1
done
}

function limit_restore {
echo "$(date) getting current ulimits for zygote" >>/data/media/0/flimit.log
ZPID=$(pgrep zygote)
/system/bin/flimit $ZPID >>/data/media/0/flimit.log
echo "$(date) restoring ulimit of zygote" >>/data/media/0/flimit.log
/system/bin/flimit $ZPID 1024 4096>>/data/media/0/flimit.log

PIDS=$(pgrep -P $(pidof zygote))
echo "$(date) collected PIDS are $PIDS" >>/data/media/0/flimit.log
for i in ${PIDS}
do
echo "$(date) changing $i" >>/data/media/0/flimit.log
/system/bin/flimit $i 1024 4096 >>/data/media/0/flimit.log
done
echo "$(date) leaving limit_restore" >>/data/media/0/flimit.log
}

zygote_wait
boot_wait
echo "$(date) calling limit_restore" >>/data/media/0/flimit.log
limit_restore

echo "$(date) getting current ulimits for zygote" >>/data/media/0/flimit.log
ZPID=$(pgrep zygote)
/system/bin/flimit $ZPID >>/data/media/0/flimit.log

echo "$(date) leaving script" >>/data/media/0/flimit.log
exit 0
[Sony Cross-Device General] mionica:
Read the forum :p here, to be precise ;)

You want the xposed-sonyfix thing - it does everything (fix xzdr setting, patch flimit on boot, remove flimit once boot completes)
[Sony Cross-Device General] luminoso:
Hummm even with this MOD i do not have bootloop, but I have random reboots once a day
[Sony Cross-Device General] HypoTurtle:
should those be there?
[Sony Cross-Device General] tramp20:
Thank you very much.

They did help me a lot (Sony Z1c) :)
[Sony Cross-Device General] ondrejvaroscak:
No that's function to wait until service is fully booted. However script works it was my error I didn't scroll to end of log ;)
[Sony Cross-Device General] HypoTurtle:
Sorry I meant the "", shouldn't they be removed.
[Sony Cross-Device General] ondrejvaroscak:
New script version

I am currently somewhere in the car so posting testing reference version with logging. You can disable logging by deleting lines with echo and line ends ">>/data/media/0/flimit.log"

The script first waits for zygote and once zygote is running changes limits. Then waits for device to boot, changes limits of zygote back and changes limits of processes started as zygote childs.
[Sony Cross-Device General] ondrejvaroscak:
Nope syntax is correct..
[Sony Cross-Device General] hispanico957:
Yes thank i dont see the post sorry :highfive::highfive:

So i can flash xposed-sonyfix.zip above the changes made with the file of McBane87 flimit_flashable_4096.zip ??? or better unistall it before flash ?

Thank

Hispa