12

I have an application in which i have some videos and audios and some inapp purchases.all r great in simulator and working perfectly.But yesterday i have created an application and trying to run on it its crashing from the begning.The error report is

malloc: *** error for object 0x165060: pointer being freed was not allocated
  *** set a breakpoint in malloc_error_break to debug

can anybody knows the solution .i dont know where it is going wrong and in simulator it is working perfectly.can anybody help me?

Sven
  • 22,475
  • 4
  • 52
  • 71
hacker
  • 8,919
  • 12
  • 62
  • 108
  • Can you think of anything that has changed since yesterday? What happens if you do a clean build? – ThomasW Aug 21 '12 at 05:52
  • yestarday i have added the provisionig files and all.and created the in app purchases.still in simulator showing no error – hacker Aug 21 '12 at 05:54
  • Can you show the problem code? Are you using free() anywhere in your app? Is your app using ARC, or garbage collection? – Chris Trahey Aug 21 '12 at 05:55
  • same ting was happening to me i tried reset content and setting in simulator and app chashed in simulator too... i had memory leak issue then.. so just check out the same.. – iMeMyself Aug 21 '12 at 06:01
  • Is your device and simulator's OS version same? – Iducool Aug 21 '12 at 06:22
  • http://stackoverflow.com/a/43885754/6521116 – LF00 May 10 '17 at 07:14

5 Answers5

5

You are probably releasing an object too many times (for example, calling alloc once and release twice). To find out where, take a look at the techniques in this question: How to find the cause of a malloc "double free" error?

I personally like the NSZombieEnabled method.

Another tip, is to set your variables to nil after you release them.

For example: [bla release]; bla = nil;

This makes sure you will not accidentally release them twice since releasing nil does nothing.

MAhipal Singh
  • 4,745
  • 1
  • 42
  • 57
talkol
  • 12,564
  • 11
  • 54
  • 64
4

I followed as talkol suggested

In my case I replaced following line

[myMutualArray removeAllObjects];

with

[myMutualArray removeAllObjects]; myMutualArray = nil;

And the error gone!

Avin
  • 301
  • 1
  • 3
  • 12
1

Please test the program for memory leaks,also check autoreleases and whether you are releasing objects properly or not.Also we need to check whether a released object has a memory allocated or not.You also need to be careful regarding autorelease,because accidentally we might release an array or a string or any object that is already autoreleased...

Here are some of the tips to trace out the exact problem:

  1. You can test for leaks by analyzing your project(click shift+command+k)

  2. Use instruments tool i.e. running for leaks

  3. Enable NSZombie in Xcode,procedure can be found here

Hope it helps and works!

Community
  • 1
  • 1
Eshwar Chaitanya
  • 942
  • 2
  • 13
  • 34
0

Without seeing any code we can't help you with this. But you can find the problem yourself, the error message even tells you what to do: set a breakpoint on malloc_error_break and you usually will find the code that caused the problem in the stack trace.

Just because it works in the simulator just doesn't mean that your code is 100% correct. some bugs only show up on a real device (or vice versa).

Sven
  • 22,475
  • 4
  • 52
  • 71
  • i dnt sd like that.if there is that problem it needs to be shown in simulator also? – hacker Aug 21 '12 at 06:07
  • this seems like a memory related bug. since the memory is arranged differently in the simulator it makes sense they would behave differently. actually, the problem probably exists in the simulator too, it just doesn't crash.. but it's bad just the same – talkol Aug 21 '12 at 08:07
  • in xode 3.2 build then there is no prblem. – hacker Aug 21 '12 at 11:41
  • 1
    There **is** something wrong with your code. And since it doesn’t show up all the time it’s an even worse bug. – Sven Aug 21 '12 at 18:09
0

This may caused by safari inspector, you can disable them. Refer to this post for more details.

enter image description here

Community
  • 1
  • 1
LF00
  • 27,015
  • 29
  • 156
  • 295