The program running in IOS prompts malloc: * error for objectpointer being free was not allocated
* set a breakpoint in malloc_ error_ break to debug
It’s clear that there are wild pointers in the program. There are several possibilities
1. There is no null assignment after C pointer free
If this problem occurs in C language, printing zombie pointer is invalid. This problem essentially refers to: when I return a pointer address in malloc, the pointer variable to this address is a wild pointer
Then it is very likely that your pointer variable has been used before. But after the original memory free, the pointer variable does not assign null, so it becomes a wild pointer
2. The pointer that may appear in the child thread or block syntax is released in advance
This problem occurs because the multithreading execution is mostly asynchronous, so there may be content when the pointer passes in the data. But when running in a child thread, other threads free the pointer
The solution is to check the method before the free language to see which method will enter other threads. If the running time of the child thread is longer, you can consider putting the pointer to the child thread free. Or use thread communication to tell the main thread when to release the pointer
Of course, if the statement is executed in the block, it may be that the related variables have been released when the block is executed. In this case, you can label the variable in the block__ Strong keyword (the principle should be reference count + 1, but the retaincount method cannot be printed in arc, so there is no specific research), to ensure that the object of the principle will not be released before the end of the block
PS: pointer is an artifact of C language. Transfer parameters with a pointer instead of structure. It’s a waste of memory and prone to problems. But the pointer transmission should also pay attention to when malloc, when free
Similar Posts:
- [Solved] C Programmer Error: double free or corruption (fasttop)
- Runtime error: invalid memory address or nil pointer dereference [How to Solve]
- R6010 -abort() has been called error analysis and solutions
- *** glibc detected *** java: free(): invalid next size (fast): 0x00000000024b19d0 ***
- Flink Project Start Error: java.lang.OutOfMemoryError: unable to create new native thread [How to Solve]
- How to Solve Python RuntimeError: can’t start new thread
- Several cases of error reporting in java.lang.nullpointerexception
- invalid conversion from ‘void* (*)()’ to ‘void* (*)(void*)’
- Linux: How to Check the Status of Page
- Stackexchange.redis timeout performing timeout problem