iOS Question Memory management

Discussion in 'iOS Questions' started by Semen Matusovskiy, Apr 17, 2019.

  1. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    Hi, guys --

    Does anyone know how IOS frees up a memory and what is correct tactics ?

    Imagine, that a page holds 100 imageviews. Pictures are static and have a fixed size.
    So it's enough to read SVG and to export to imageview once.

    In some moment the app switches to another page. And what to do with Imageviews on first page ?
    To remove ? But in this case the app will need a time to recreate imageviews, when user switches to initial page again.

    Probably, IOS uses virtual memory (like in Windows). Maybe not. Any ideas ?
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Have you encountered any memory issue?
     
  3. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    No. But I began to convert only.

    In B4A I removed everything, what it was possible (to avoid memory leaks).

    In B4I there is a wish to keep in global variables and do not destroy views (most of layouts are static).
    If this is a wrong tactics, I don't want to find this on final stage :)
     
  4. sorex

    sorex Expert Licensed User

    you can always use a static amount of imageviews and just change its content (bitmap) when a page change is requested and hide what's not needed.
     
  5. CaptKronos

    CaptKronos Active Member Licensed User

    I have a similar concern/confusion to Semen. Coming from B4A where each activity is released once it is no longer being viewed, it seems strange to have all the iOS pages seemingly in memory all the time. However, I have never had any memory issues, so perhaps iOS is just very clever at swapping memory in and out?
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    iOS is simpler and more flexible in this area. You can remove all views if you like when a page disappears. However I would only do it if you actually see a problem.
     
  7. Semen Matusovskiy

    Semen Matusovskiy Well-Known Member Licensed User

    I found old article https://developer.apple.com/library...tual/ManagingMemory/Articles/AboutMemory.html
    It looks that there are serious restrictions for IOS

    I can agree that there is no reason to remove regular views (such as Label, TextView etc). They should not take a lot of memory anyway. Meanwhile iPhones have 1-3 GB of RAM.

    But about graphic I am not so sure. If to take standard density (3 pixels per unit) even small picture 50 * 100 requires (50 * 3) * (100 * 3) * 4 = 176KB. So, I decided to reset imageview (according sorex's recomendation).
     
    Last edited: Apr 17, 2019
  8. Computersmith64

    Computersmith64 Well-Known Member Licensed User

    ViewController classes in apps written in Xcode have a didReceiveMemoryWarning function by default:

    Code:
    override func didReceiveMemoryWarning() {

            super.didReceiveMemoryWarning()
            // Dispose of any resources that can be recreated.

        
    }
    You can use this function to take appropriate action if there is a memory issue. I'm not sure if it is implemented in B4i.

    - Colin.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice