This is a piece of code that I wrote in xcode
Foo * myFoo = [[Foo Alok] Init]; [Myfu release]; [MaiFoo print message];
If I am correct, then I should give a runtime error when the print message function is called, because Mufu is delinked from that time. But in the xcode, the code is working and the print message is being called, is it a problem because it is set to the xcode?
Ridge Abhijit
By applying undefined behavior by accessing free memory Are there.
It may crash, it can work properly, as a result of which your mistakes are nose.
To detect memory errors when you are developing code, you should enable NSZombie, see instructions here:
Update
You may wonder why this works - surely the OS should always throw an error when you try to access memory which is not valid?
T always get an error (and why the behavior is undefined) that the memory checking will be a performance penalties valid on every entry - ie the code will run slowly, just to check some which Should never be.
So you have to be careful to hide all these errors during development, so that they never end up for the end user NSZombies is the best tool to find them.
Another point - if you do "build and analyze" in the exode, then it can also get this error on creation time . Certainly static analyzer builds up some memory errors at build time.
Comments
Post a Comment