Has anyone figured out how to resolve this issue?
Post
Replies
Boosts
Views
Activity
Thanks for your input. I will google around to find some information and see how it goes.
It looks like the "leaks" instrument output provides the stack trace of where the memory leak occurred. If this is true and I do not see any of my functions displayed in the stack trace then I do not know how to progress the issue. I do not even know where other code exists which was not originally written by myself.
My application does not cache any specific game data, files or URL images so I do not know of any cached files or memory which I could free when a didReceiveMemoryWarning( ) was received. The memory leaks, which were reported by the "leaks" instrument, are not pointing to any functions that I created in my code so I have no idea how to progress those. The memory leaks are related to functions which make no sense to me. Knowing I just taught myself swift coding and just created my first application only, I do not currently posess the knowledge to know how to progress issues in code which I did not even write.
My friend did indicate she had a lot of other applications opened and has only 2Gb left of overall available space on the iPhone. I guess this might explain the memory issue.
The reason I created this post was due to the fact that one of the players who I was playing against was kicked out of my game application due to didReceiveMemoryWarning() being called. I have never seen this memory warning occur while testing for the past many months. I assumed I might have some memory leaks since I never checked before or possibly be using too much memory in my application. I read somewhere that setting UIImages to nil might free up memory so I thought I would look whether this was true, so decided to start this post.That being said, I just recently performed the following and concluded I do not have any memory leaks in my application:I ran the "leaks" instrument while running my application on my real iPhone device (ie: leaks does not work on the iOS simulator running 13.4). The leaks tool never reported any leaks in my application code. There are however various leaks occurring (64bytes, 128bytes, 256bytes in other code which I do not change). I am ignoring those areas.I ran "Malloc Stack (Live Allocations Only)" and did not see any purple exclamation points in the Debug Navigator everIn the "Debug navigator" I clicked on "Memory" and saw my application runs at a constant 49-51MB from start to finish whether 2,3 or 4 players are in the game. If I was leaking memory I assume this memory usage amount would steadily increase throughout the 20-30 minute gameplay to some value much much higher
I will look into what Leak is ... thanks
I understand using "UIImage(named: ***)" to load an image onto a UIButton or UIImage will result in the image file being cached automatically. Since the total size of all 52 card images combined together have a small total size of 1/2MB only then I am assuming this automatic caching of images is not what is causing the didReceiveMemoryWarning( ) one of the players received while playing the game.I was trying to determine whether anything in my application was wasting memory but really do not know how to go about figuring this out. I was thinking it might be due to loading images into UIButton and UIImage views, but know I do not know what to think. Question:If I have 6 UIImage views on my storyboard and eventually load 52 different card images onto each individual UIImage while playing many rounds of my game, then does each UIImage view cache 52 separate images individually (ie: 52 images x 6 UIImage views = 312 cached images) OR does the system only cache the total 52 card images only?
Setting the UIButton image to NIL and UIImage image to NIL before I reload it does not seem to resolve my memory issues. It may reduce the memory a bit, but I am not sure how to tell for certain. mute_Button.setImage(nil, for: .normal)
mute_Button.setImage(UIImage(named: muteOffImageFile), for: .normal)imageObj.image = UIImage(contentsOfFile: "")
imageObj.image = UIImage(named: imageFile)
there is no url or www it is just normal text as far as I can see.toggling the MUTE button in my application causes the following print statments to be displayed :Finally figure out the issue was with the <number> ... see belowI cannot provide the 12-digit <number> below since it will be moderated if I include itmute_Button = Optional(<UIButton <number> frame = (324 35; 35 35); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x603000132fd0>>)mute_Button = Optional(<UIButton <number> frame = (324 35; 35 35); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x603000132fd0>>)mute_Button = Optional(<UIButton <number> frame = (324 35; 35 35); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x603000132fd0>>)mute_Button = Optional(<UIButton <number> frame = (324 35; 35 35); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x603000132fd0>>)mute_Button = Optional(<UIButton <number> frame = (324 35; 35 35); opaque = NO; autoresize = RM+BM; layer = <CALayer: 0x603000132fd0>>)<number> = 0 x 6 1 7 0 0 0 0 8 0 3 8 0
>>I don't want to see the description, but the object instance itself:print(mute_Button)This print statement displays a long hex value for the UIButton. This seems to be the actual address of the UIButton itself since this address does not change when I switch the button image. The print statement also prints out "frame, opaque, autoresize and layer " data as well.It does not seem like the actual UIButton instance (address) is changing when I reload images.Do you think UIImage image would act the same way?To set a UIImage image to NIL before reloading I am doing the following: Is this correct?imageObj.image = UIImage(contentsOfFile: "")
imageObj.image = UIImage(named: imageFile)
I tried manually retying all the text output by hand by still "currently being moderated"I have no idea how to show you the text output, sorryCan you please let me know how you would set a UIImage (not UIButton) to NIL?
The following print statement in my code displays text which I cut and pasted into this post. However, the post now states it is "currently being moderated" for some reason so I guess you cannot see it. I had to remove the print output so I could post this responseprint("mute_Button = \(mute_Button)")
It is very frustrating that posts indicate "currently being moderated" when there is nothing visually wrong with the text I am including
1) With the code below, I see the following output print statementsprint("mute_Button = \(String(describing: mute_Button))")
mute_Button.setImage(UIImage(named: muteOffImageFile), for: .normal)print output not allowed to be displayed ... since It is "Currently Being Moderated" for some reason. Always happens .. UGH2) To set a UIButton image to NIL before reloading I am doing the following:mute_Button.setImage(nil, for: .normal)
mute_Button.setImage(UIImage(named: muteOffImageFile), for: .normal)3) To set a UIImage image to NIL before reloading I am doing the following: Is this correct?imageObj.image = UIImage(contentsOfFile: "")
imageObj.image = UIImage(named: imageFile)