Determine Free Disk Space Allowed By Sandbox On iPhone - objective-c

I am looking for a way to determine how much free disk space there is available to my application.
I have tried using NSFileManager's fileSystemAttributesAtPath with NSFileSystemFreeSize, but this is giving me the total free space on the iPhone and not what is available to my application by the Sandbox.
I believe applications are limited to using 2 Gig of space, and need to show how much of the 2G is still available.

You can use statfs(2) and check the f_bavail field. This is the amount of space available at the moment to an unprivileged application, so it should give you the modified space that your application is permitted to use.
You can see the iPhone version of the man page here.

Related

20 MB - is it the minimum package size for our puzzle game made with Unity?

We have created a simple puzzle game with Unity. The final package apk size is 20 MB. The size of our graphic and sound assets combined is 6 MB. We have already tried to do optimization as we found some tips on the Internet (before it was 28 MB).
The question is for experienced developers and it is very simple:
Please let us know if 20 MB is the smallest size that we can achieve? If not, then please let us know your opinion what can be the smallest size for this kind of game? It has only one level.
The link of a game: https://play.google.com/store/apps/details?id=com.strategeens.kineticpuzzle
Yes it's reasonable. Unity3D has quite a large footprint itself. Depending on the platform it should be even more that 15MB for the engine itself.
You can check Editor's log to see how much memory is taken by your assets, the rest are binary and engine's internal resources.
As a rough measurement, just try to deploy an empty project with a single scene on the desired platform and you'll figure it out.
On Unity 5 they started to modularize a little bit the engine (see this post).
One of the reasons, is space. One of the benefits is that you'll should be able in the future to build only modules relevant to your game (es. no need for physics? don't build PhysX).
In your player settings, you can change device filter to ARMv7 only, which will reduce your build size, but your compatibility with certain devices will suffer. Also, change Api compatibility level to .NET 2.0 subset and Stripping level to Strip Byte Code or even Use micro mscorlib. You can read more about these settings in the manual.
However, I must say that 20 Mb is pretty small for Unity application, and is pretty good from a product side of things. If, however, you begin to reach the 50 Mb limit, then you really need to worry. You'll have to implement OBB split if you decide to go over 50 Mb limit.

get available memory in winrt

I want to plot a larger amount of data within an metro application and I need to buffer this. To find out how far I can buffer it would be great to know how much memory is still available (to my app), this shouldn't inlclude virtual memory.
Is there any way in a metro app to get this Information? I only found GlobalMemoryStatusEx, but that can only be used in desktop apps
Thank you
I just had to deal with this and got hold of the right people at Microsoft to answer this. Unfortunately the answer was : No you can't do that, except use the restricted calls that you found but using those prevents you from getting certified for publication in the store.
How about just trying to allocate a lot of memory in chunks. When it first fails - add up the sizes of the chunks and either release them or use them for your operations.

Is 4 GB of RAM necessary windows phone 8 development?

It is mentioned on MSDN page,is the requirement strict?My system has 3 GB of RAM and I am not thinking about upgrading my system's ram anytime soon.
Also can I ignore Visual Studio,Windows phone 8 sdk on the whole if I pick up marmalade sdk as the primary development tool?
As someone who has to estimate system requirements with some regularity, I take minimum system requirements with a grain of salt. The minimum requirements have some padding, because nobody really knows where the edge really is, and as estimators we have to play it safe.
Usually, you can get stuff to run even if you don't meet the minimums.
Note that this doesn't mean that it will run well.
Not sure about Marmalade. You should consider separating these two questions into separate postings.
For successfully developing windows phone application minimum hardware requirement is necessary.

Data usage from any application

I want to read how much data from 3G every app uses. Is this is possible in iOS 5.x ? And in iOS 4.x? My goal is for example:
Maps consumed 3 MB from your data plan
Mail consumed 420 kB from your data plan
etc, etc. Is this possible?
EDIT:
I just found app doing that: Data Man Pro
EDIT 2:
I'm starting a bounty. Extra points goes to the answer that make this clear. I know it is possible (screen from Data Man Pro) and i'm sure the solution is limited. But what is the solution and how to implement this.
These are just hints not a solution. I thought about this many times, but never really started implementing the whole thing.
first of all, you can calculate transferred bytes querying network interfaces, take a look to this SO answer for code and a nice explanation about network interfaces on iOS;
use sysctl or similar system functions to detect which apps are currently running (and for running I mean the process state is set to RUNNING, like the ps or top commands do on OSX. Never tried I just suppose this to be possible on iOS, hoping there are no problems with app running as unprivileged user) so you can deduce which apps are running and save the traffic stats for those apps. Obviously, given the possibility to have applications runnning in background it is hard to determine which app is transferring data.
It also could be possible to retrieve informations about network activity per process/app like nettop does on OSX Lion, unfortunately nettop uses the private framework NetworkStatistics.framework so you can't dig something out it's implementation;
take into account time;
My 2 cents
No, all applications in iOS are sandboxed, meaning you cannot access anything outside of the application. I do not believe this is possible. Neither do I believe data-traffic is saved on this level on the device, hence apple would have implemented it in either the network page or the usage page in Settings.app.
Besides that, not everybody has a "data-plan". E.g. in Sweden its common that data-traffic is free of charge without limit in either size or speed.

why the available free space in the device is changing frequently in iphone sdk?

In my application I'm displaying available free space for my application in the device. The value is changing every time when I launching the application. Why is it happening like this.
Initially my available free space is 30,752,768 bytes and after allocating all the objects the available free memory is :2,809,856 bytes. after this I added some images to the view by using camera option then I received memory warning level = 1 and after that i get free memory space as 12,705,792 bytes. Why it is increased like this.
Can any one help me.
Memory warnings trigger a release of unneeded objects. This may include views that are not displayed and intermediary data that does not need to be in memory, especially stuff that can be recreated as needed – perhaps even pre-scaled images.