Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Device [Ram] check

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

  1. TSC

    TSC

    Joined:
    Oct 15, 2012
    Posts:
    241
    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:
    207
  3. TSC

    TSC

    Joined:
    Oct 15, 2012
    Posts:
    241
    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:
    241
    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:
    7,627
    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:
    241
    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???)
     
unityunity