Search Unity

Device [Ram] check

Discussion in 'Scripting' started by TSC, Aug 1, 2017.

Thread Status:
Not open for further replies.
  1. TSC

    TSC

    Joined:
    Oct 15, 2012
    Posts:
    271
    What's up everyone, first let me finish with as always stay productive!!!

    Topic - RAM Check


    OK here's what I'm looking to do:

    I'm looking to create a small block/method to return the current system RAM and based on that limit certain functionality within the app (current target Android).

    Having it where users are not allowed to download the game is bad for business just as well as the game crashing due to lack of RAM when certain functions get called.

    As of now the two most expensive calls within the app are run Ads and IAP initialization.

    Is there a way for me to add a check RAM before call method or line within the call method, and if RAM is sufficient execute , if not prompt user your device does not have enough RAM for this.

    That way users with less RAM can still play the game. Users with more RAM wont miss a beat and me on the end of Development/Business won't loose sleep and half a brain over this matter..

    I'm not looking to leave anyone out here!!!

    Have anyone developed a solution of such or can anyone point me in the proper direction to achieve this.

    Thank you.

    --Grand Rio
     
  2. Zenix

    Zenix

    Joined:
    Nov 9, 2009
    Posts:
    213
  3. TSC

    TSC

    Joined:
    Oct 15, 2012
    Posts:
    271
    Thanks and I seen that along with several other post and also I looked it up in the uDocs as well before posting. When you arrive there and select "see Also: SystemInfo.systemMemorySize" or "see Also: SystemInfo.graphicsMemorySize" they loop to one another...????...??

    also would I need a certain namespace to access this or..
     
    Last edited: Aug 1, 2017
  4. TSC

    TSC

    Joined:
    Oct 15, 2012
    Posts:
    271
    Do I go...

    Code (CSharp):
    1. public int deviceMem;
    2.  
    3. public int deviceMemNeeded;
    4.  
    5. public Awake()
    6. {
    7. deviceMemNeeded = 2048;
    8.  
    9. //this
    10. deviceMem = SystemInfo.systemMemorySize;
    11. //or
    12. deviceMem = SystemInfo.graphicsMemorySize;
    13. }
    14.  
    15. public int returnMem(){
    16. int mem;
    17.  
    18. mem =  SystemInfo.systemMemorySize;
    19.  
    20. //or
    21.  
    22. mem =  SystemInfo.graphicsMemorySize;
    23. return mem;
    24. }
    25.  
    26. public void callMethod(){
    27.  
    28. if(returnMem() < deviceMemNeeded ){
    29. // prompt you do not have enough RAM for this action
    30.  
    31. return;
    32.  
    33. }else{
    34. //execute... do something
    35. }
    36. }
     
  5. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,686
    Do you have even a single datapoint indicating you have a problem with users exceeding the available RAM?

    Don't waste time trying to solve problems you probably don't have in the first place. Instead, focus on making more games and making the ones you have more fun.
     
    TaleOf4Gamers and Kiwasi like this.
  6. TSC

    TSC

    Joined:
    Oct 15, 2012
    Posts:
    271
    Devices with 1024 or less RAM seem as thought they can't handle the Ads and IAP call functions. Yes several phones that I test with will shut out and restart, They one that it works fine on has 2048 RAM it's the others...

    All I'm looking to do is get device ram, if it's less than 2048 disable ads and IAP , by doing so this will still allow users to play the app (where is the fun if you can't even run the app???)
     
    tms_dev likes this.
  7. tms_dev

    tms_dev

    Joined:
    Nov 26, 2018
    Posts:
    47
    @TSC Did you ever get this figured out? Sorry about the Kurt guy, what a rude person :(
     
    radiantboy and Kurt-Dekker like this.
  8. tms_dev

    tms_dev

    Joined:
    Nov 26, 2018
    Posts:
    47
    The most info I found is `SystemInfo.systemMemorySize` is the total memory that should be on the phone. Apparently it also doesn't work on some phones like Note, where it returns incorrect information: https://forum.unity.com/threads/sys...-note3-and-newer-devices.221262/#post-1476803

    And where do I look if I want to find the total memory AVAILABLE, not used? Maybe `systemInfo.graphicSize`?

    Honestly, I'm a bit lost here. I would appreciate any help, thank you!
     
  9. That's kind of the name of the variable. It is self-explanatory.
    That I don't know. If you experience that it is buggy, submit a bug report, I'm pretty sure Unity Engineers would like to fix it if it isn't working properly.
    It is not related to the question. AFAIK Unity doesn't provide such an information.
    ??? Why would it be? Why would be the available >system< memory called >graphicsMemorySize<?

    And at both variable the documentation clearly tells you what they are representing. (eg: "Amount of video memory present " at the graphicMemorySize).

    Now if you think there is no available method to get the available system memory on a device, and you think it is possible, and you think Unity should provide such information (I doubt that it would be the best strategy, personally, but that's my opinion only), then you should open a new thread in the relevant Platforms topic (eg, iOS, Android, whatever) and mark it as "feedback" (next to the title when you edit your new thread). We can ask for features this way for a while now.
     
Thread Status:
Not open for further replies.