Memory management in corona sdk - coronasdk

I have done one project in corona sdk for iPad and android,in that four main modules are there,and one module also has some sub modules.for changing the scenes I used director class.
Eventhough I followed every memory management techniques,my project is quiting within 15 minutes,is there any solution for this?thanks in advance...

Have you tried solutions from memory leak prevention article? You can display/log current memory usage and try to find what is allocating the memory. That plus additional debugging would help you find where the problem actually is and what is allocating the memory.
After location of the problem is known you need to determine why the memory is not freed. E.g. make sure you're correctly removing objects from the scene:
display.remove( redBall )
redBall = nil
See also the discussion on Corona SDK forum:
http://forums.coronalabs.com/topic/3637-how-do-i-tell-if-my-game-is-leaking/

Related

High Memory usages and after that app crash ,when using Multiple image selection library in Swift

I am working on multiple image selection, here i used a library BRImagePicker inside project. the issue is that when i start using this libraries functionality it uses memory in high volume and after that app crash with this error message "Message from debugger: Terminated due to memory issue".also checkout the image of memory uses and help me to resolve this issue.
If you look at the BRPhotoPickerController.m file under Controller group, there is a line:
info.originalImage = [UIImage imageWithCGImage:[representation fullResolutionImage]];
A memory is allocated for each photo/video in the library.
This image or video is in its full resolution which means memory will get full within seconds after the picker is presented.
The approach is inappropriate since the original photos/videos are retained in memory.
Instead what you can do is to keep a reference like the media's URL and refer back to it later.
This thread may also be helpful.
Since you have not shared any code, I encourage you to read these articles to find the memory leak and/or zombie objects:
Find memory leaks in iOS apps with XCode Instruments
Identifying Memory Leaks using the Xcode Memory Graph Debugger
Xcode Instruments — Zombies
Update:
The original library is outdated, its last update was 4 years ago and I assume you are porting it to Swift. What Soroush pointed is the what I said earlier. You should not keep a lot of UIImages in memory, to fix it you need to both keep reference to assets, and unload invisible cells. To get an idea check this library https://github.com/tilltue/TLPhotoPicker .

how to manage memory allocation issue in ios ARC proejct

i am working on project in which application memory usage increase continuously even i am on same view and app in idle
i am using ARC, dealloc also not called.
most on my properties are nonatomic and retain.
XCode has a built-in memory profiler that can help you with this issue - for a tutorial on how to use it, this might be helpful http://www.raywenderlich.com/23037/how-to-use-instruments-in-xcode
Otherwise, if dealloc isn't being called it could be a symptom of a retain cycle (two objects maintain strong references to each other, so they are never deallocated).
You can find fix the Memory Leaks using Analyze option of XCode
Open XCode --- Product --- Analyze
Then you can find the memory allocation issues locaton with blue identification.
You can fix them where you not using any object which are allocated and so on....
Hope it helps you..

Potential Memory Leak in iOS

So I just made an app that loads a map with some markers on it. The app has a navigation controller that segue from the main screen to the map and back. While running the app on my phone and simulator i noticed that if i went back and forth between the home screen and the map, the amount of memory that the app was using just kept growing indefinitely. Is there way to assist in the process of memory management (i know the system uses ARC)? Im using the google maps sdk btw.
Thanks!
Does it cause the app to run out of memory and crash?
Or is it using a ton of memory, receiving a memory warning, and dumping said memory?
So, unless it is causing crashes, it may be behaving correctly.
Apple has extensive and well-documented support for diagnosing these kinds of problems. See "Locating Memory Issues in Your App".
Check your codes where using NSThreads and GCD blocks. If there are some places you create plenty of threads, it is recommended to add a autoreleasepool block.
Memory may leak in these situation:
If you are writing a program that is not based on a UI framework, such as a command-line tool.
If you write a loop that creates many temporary objects.
If you spawn a secondary thread.
For reference: Using Autorelease Pool Blocks

Understanding task_basic_info task resident_size

short question: someone (cit. 5) told me that resident memory could be reclaimed by my system. What does this mean? Does it mean that my App is not using that memory or is the resident memory value directly related to the memory being currently used by my App? I haven't found much documentation on this apart from those answers.
I am trying to solve an issue. I am writing a game usign iOS 6.0 and Cocos2d 2.0 and I do get some memory problems. I have Cococs2d 2.0 as static library and I wrote my code using ARC (which I suspect being the reason).
Going from Initial scene to Character Selection Scene and then to Planet Selection scene and finally Game scene I observe that the resident_size of memory increases.
I added this code at each scene init and I tracked down the values. The following picture show the user experience path I do. On the left colum there are the scene names, on the second colum the amount of memory used in the normal flow (not going back to the previous scene) and in the third block of colums there are the values of resident memory going back and forwards from specific scenes.
As we can observe the Main scene presents an issue probably different from the other scenes. Every time I load the scene I get a memory increase of about 15 MB.
I run an indipendent test on the scene (using a reload callback method) and I get the following values:
Interestingly, running the same test on the CharacterSelection Scene does not have a progressive increase of memory after the third load (stays 37MB). However I do not understand why initially goes from 27 MB to 32 MB and NOT to 37MB (or, I should say, I do not understand why it goes from 32 MB to 37 MB).
I run another set of test trying to parse from one scene to the other and I do get interesting results. Here is the schema:
**Someone answered to me saying "Resident memory is a measurement of the memory that has been allocated to your application and has not yet been reclaimed by the system, but some/most of the resident memory could be reclaimed by the system."
Does this mean that resident memory values are not necessarily memory used by my App?
According to my test, there does seem to be a correlation between scenes and their memory used and resident memory value.
So if this is correct I should keep trying to solve this issue as the higher the resident memory value is the more likely my APP is to be killed. If, instead the memory would be available to the system to be used then there would be no crash. Given that there are crashes I assume that the memory is somehow leaked. However the leak tool does not detect any leaks (is this because I am using XCode 4.5?).
Any help? Is this related to using ARC?
The issue was that I was measuring the memory during the init method of the new scene. The report was hence including the assets of the previous scene (as it was not yet being deallocated).
Adding a callback with a 0.1 delay solved it and answering my questions:
Q:
someone (cit. 5) told me that resident memory could be reclaimed by my
system. What does this mean? Does it mean that my App is not using
that memory or is the resident memory value directly related to the
memory being currently used by my App?
A:
it is the memory directly related to the memory being used by my App. Using a delay in the callback of this function plus a call to [[CCTextureCache sharedTextureCache] dumpCachedTextureInfo]; will confirm this.
Q:
Any help? Is this related to using ARC?
A:
Not in this case fortunately. There where other issues causing leaks in some scenes. For example, the starting scene was subclass of another scene. This starting scene had some child nodes being added as child which where not being removed on the cleanup method of the scene. Adding an explicit removal of those child nodes solved the issue. I am not sure why this was necessary (I was expecting all child nodes to be automatically removed) but it solved the issue.

ARCGIS iOS - map layers memory issue

In my application I used arcgis sdk. I have 3 different map so I used 3 tiled map service layers. And also I have a graphic layer to show symbol for selected specific region on the map. My app; first connects the services with credential and then adds the layers to the map view. So far there is no problem. After loading all of layers, I started to use AGSQueryTask and AGSIdentify task for some query operations. Here the problem starts. The debugger gives me "Received memory warning. Level=1". I continue to do zoom/pan, and extra query operations. After a while, my app crashes giving no error. I reviewed my code, googled about my problem, looked around in arcgis forums however I didn't find a solution and good explanation. I tried my app with 1 map not 3 but the warning and crashing didn't disappear. I also deal with hidden property of layer view again there is no improvement.
After all, is there anyone who knows a solution or an explanation or an assumption to my memory problem?
P.S. I also debugged my code with nszombienabled and guard malloc thanks to stackoverflow:) In this process I came across ": CGBitmapContextInfoCreate: unable to allocate .. bytes for bitmap data". Is my memory problem related to this error?
Thanks in advance.
This sounds really like some memory leaks or not releasing memory which is not used anymore by your app.
There is no general solution to be given, because the cause of those problems could be anywhere and be anything.
What you could do is:
ensure that you have defined didReceiveMemoryWarning methods in your classes and that you try to free not used memory there;
running your app under the Leaks and Memory Allocation profiling tools and see what you can to about what they report to you;
if you do not have memory leaks, try and use snapshot analysis to find abandoned memory.
In this process I came across ": CGBitmapContextInfoCreate: unable to allocate .. bytes for bitmap data". Is my memory problem related to this error?
If you fill up the memory, the allocation call can fail... this is rather an effect, more than a cause.

Resources