XPrivacy icon indicating copy to clipboard operation
XPrivacy copied to clipboard

Out of memory

Open unclefab opened this issue 13 years ago • 88 comments

I'm on v 1.77. When I try to import my settings back up file it stops like in the middle of the process and gives me an java.lang.OutOfMemory error.

unclefab avatar Jul 23 '13 15:07 unclefab

Out of memory errors cannot be fixes, they are what they are.

M66B avatar Jul 23 '13 16:07 M66B

Ok, but I didn't have this problem with previous versions, actually until 1.75...

unclefab avatar Jul 23 '13 17:07 unclefab

I guess you have set more restrictions since then.

M66B avatar Jul 23 '13 17:07 M66B

Mmmmh, I see... So I will investigate, thanks for the info!!!

unclefab avatar Jul 23 '13 17:07 unclefab

I have same issue with import. I have 16GB HTC One S with very moderate amount of apps: 199 in total - 55 user apps and 144 system apps, as reported by Titanium Backup. I have around 680MB of free internal storage and around 520MB of free RAM in everyday use. Currently, my XPrivacy xml file size is 303KB (yes, I have a lot of restrictions active). There are 3123 entries for all these apps - an average 15 per app. And each restriction added in XPrivacy app make my file bigger even if I don't change anything. I've tried to reinstall XPrivacy and Xposed, also tried to kill as many apps as possible to free more RAM but nothing helps. My workaround is to Titanium Backup to restore XPrivacy, but others may not have backup. I understand this is not strictly XPRivacy problem, but you might look at this issue. Users who have devices with less memory and/or more apps should be affected as soon as they start do dig deeper and apply more restrictions. I don't know anything about Android development, but have some programming background. My suggestions could be an educated guess at bwest, but here are two ideas:

  • Instead of loading complete xml file in memory during the import, load the file in chunks of manageable size.
  • Apply reverse logic on xml entries: all permissions and functions should be consider restricted (checked) by default and xml file will contain only unchecked (not restricted) items.

pogovault avatar Jul 24 '13 19:07 pogovault

I will see how I can improve this. Hopefully I don't have to write my own XML parser and can the built-in parser be tweaked.

M66B avatar Jul 24 '13 21:07 M66B

I will switch to the SAX parser to save memory. http://developer.android.com/reference/javax/xml/parsers/SAXParser.html

M66B avatar Jul 24 '13 22:07 M66B

Could you please test if this version works okay for you: http://d-h.st/Eyb (if you have a file manager installed, there is a bonus ;-)

M66B avatar Jul 25 '13 07:07 M66B

See also #327

M66B avatar Jul 25 '13 07:07 M66B

Same error, but work longer than before.

Marcel Bokhorst [email protected] wrote:

Could you please test if this version works okay for you: http://d-h.st/Eyb (if you have a file manager installed, there is a bonus ;-)


Reply to this email directly or view it on GitHub: https://github.com/M66B/XPrivacy/issues/329#issuecomment-21537923

Sent from my Android phone with K-9 Mail. Please excuse my brevity.

pogovault avatar Jul 25 '13 14:07 pogovault

There is little more I can do than I already did, sorry.

M66B avatar Jul 25 '13 15:07 M66B

Maybe change xprivacy to use a sql database. and export the data base as such.

May solve the memory errors and if you locate the database in /data like pdroid it will keep nosy and malicious apps out of it.

GhostlyCrowd avatar Jul 25 '13 15:07 GhostlyCrowd

That would not be compatible across devices.

M66B avatar Jul 25 '13 15:07 M66B

Doesnt just about every messaging app use SQL for its database? android includes sql as well as default. and 2.3+ allow the use of the WAL sql database system. It would probably improve the performance alot if this can be done.

Can you explain more why it would not be corss-device compatible? I dont understand why it wouldn't considering my above statements. As for putting it in /data your app will need rood access. but every one who uses exposed framework has to have root anyways. so no issues there.

GhostlyCrowd avatar Jul 25 '13 15:07 GhostlyCrowd

There are different versions of SQLite database, depending on Android version.

M66B avatar Jul 25 '13 15:07 M66B

well, you can address it the same way other devs do could you not? You could even include your own version of sql binary. alot of backup apps and tweaking apps do this already.

GhostlyCrowd avatar Jul 25 '13 15:07 GhostlyCrowd

Too much work that I rather spent on something else (for example restricting Android 4.3)

M66B avatar Jul 25 '13 15:07 M66B

Fair enough. But If this goes un solved, the inability to import ones settings is going to detour some users and pro users.

I don't have the issue "yet"

But keep in the back of your mind that this issue is fixable with my suggestion of moving to a sql database, and eventually people will expect it to be. I would make this "low prio", not "will not fix" in my opinion.

And again just to mention it would probably improve performance, which i know you have been aiming for.

GhostlyCrowd avatar Jul 25 '13 15:07 GhostlyCrowd

@GhostlyCrowd An SQLite database doesn't necessarily use less memory. The situation with the new XML parser has greatly been improved. The memory footprint of the new parser is magnitudes lower that the old one.

@pogovault which device are you using and how much free memory do you have?

M66B avatar Jul 25 '13 15:07 M66B

Also the answer to this stack overflow question hits the nail on the head for the issues your having

http://stackoverflow.com/questions/5213550/raw-resources-versus-sqlite-database/5213569#5213569

easier and faster to retrieve sort and filter data and it has none of the limitations you are getting with SAX or the previous xml parser.

As xprivacy grows so will the things its filtering, sorting and what not. I still suggest you consider this.

As devices become more powerful it will not be uncommon for a user to have 300-600 apps. So what then?

if users are having issues importing settings for 200-300 apps now. thi9nk about the future.

GhostlyCrowd avatar Jul 25 '13 15:07 GhostlyCrowd