memory leak in AudioToolbox library AVAudioPlayer - memory-leaks

Is there a memory lead issue with the AVAudioPlayer object? I'm getting a memory leak when using AVAudioPlayer in the simulator. It doesn't matter how I created the AVAudioPlayer. I've used initWithContentsOfURL and InitWithData. Below is a snippet of the code. Full project # Github https://github.com/docchang/MemoryLeakAVAudioPlayer
NSError *error;
NSURL *playerURL = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:#"Bell" ofType:#"m4a"]];
self.playerWithURL = [[AVAudioPlayer alloc] initWithContentsOfURL:playerURL error:&error];
if (!playerWithURL) {
NSLog(#"no %#.%#: %#",#"Introduction2", #"m4a", [error localizedDescription]);
}
playerWithURL.volume = 0.9f;
playerWithURL.numberOfLoops = 0;
[playerWithURL play];
However there is no memory leak when testing it on the device. This issue is starting to leaning towards issue with the AudioToolBox library, but just want to confirm it with stackoverflow folks.

I am getting the same memory leak when using AVAudioPlayer. I have seen a few posts about similar occurrences of this leak with the AVAudioPlayer and VideoPlayer libraries around the web. It appears to be a problem with the library itself (blame Apple):
iPhone: OpenAL & AudioToolbox leak
https://appcelerator.lighthouseapp.com/projects/32238/tickets/1992-ios-strange-behavior-and-intermittant-mem-leak-on-embedded-video-test-case
Edit: Also seeing the leak disappear when the target is run on the device.

Just ran a test as I was experiencing the same issue. Instruments showed a leak at the start of an app when sound was played using AVAudioPlayer. It was only registered once at the start. The sounds generated afterwards have not had any further leaks.
When I ran the same app build on my iPhone using Instruments, there was no leak at all.
I'm running iOS 11.2.5 and Xcode Deployment Target is 11.0
Looks like it is just an Xcode bug but could be related to MacOS.

Related

Strange event behavior in Node.js and C++ DLL integration through node-ffi

I'm working on a NW.JS-based application that uses a document scanner. Since the API for that scanner is packed in a OCX component, I had to build a wrapper DLL in C++ and call this wrapper through the node-ffi module.
The scanner API is event-based, so it fires events for almost everything. From hardware initialization to image generation when processing documents.
The issue I'm facing is when the scanner notifies my wrapper layer about the images from the document being scanned. The API fires the event twice, one for the front image and another for the rear image. When testing the wrapper DLL using a console application, everything works fine and I can get the two images from the document. If I call the DLL from node-ffi (through my NW.JS application) the behavior is almost the same, except that I get only the front image from the document.
I analyzed the behavior of the two applications using WinDbg and I could notice that everything seems to be the same between the two tests. The only difference is that the event for image generation is being fired only once when testing from the NW.JS application.
It's very strange and I'm running out of ideas about what to investigate. Does anyone here have faced this kind of issue?
Any ideas and hints are welcome.
Thanks!
After having a hard time hitting my head on the table I discovered that the problem was caused by a typo in a configuration file.

Running sample projects in MvvmCross v3 (Hot Tuna)

I'm trying to run sample projects (viz. BestSellers and Conference) that are present in MvvmCross v3 branch. I resolved the strong assembly reference issues successfully. However each time I run a sample project, I get System.TypeLoadException in MvxFullBinding and MvxValueConverterRegistryFiller classes.
Exception in MvxFullBinding class:
Exception in MvxValueConverterRegistryFiller class:
Is anybody able to run the sample projects successfully? How do I get around these exceptions?
It looks like you're running this as the 'Touch' projects from Visual Studio? In which case you are way ahead of what I've managed to achieve.
If that is correct, then I suspect that what you are seeing is that you have:
built proper PCLs built in VS/Windows against the portable reference assemblies
but these cannot be executed against the current MonoTouch/Xamarin.iOS runtime.
If you try, you may see issues like: iOS black screen and MissingMethodException: Method not found: 'System.Type.op_Equality'
For some more info see 'almost portable binaries' on http://slodge.blogspot.co.uk/2013/01/almost-portable-binaries.html
There is 'proper' PCL support currently being worked on within XamLabs - so I am hopeful that there may be a solution to this problem arriving in the Xamarin.Android Alpha channel any day now - but don't expect this to be painless initially.
Of course, I might be wrong on this - this really is new territory and I will be fascinated to hear/read about your adventures. If you want to try to find more detail, then it may help to try looking deeper into the exception details, and looking into the console log trace on your mac.
For these two particular exceptions, I can confirm that both samples...
... although that is when I'm working on my Mac.

core data automatic lightweight migration failing on ios5

I have a new version of my model which has one extra attribute in one the entities and nothing else really.
I have setup automatic migration as there is nothing else to migrate,and what happens is that in ios4.3 it works as expected but in ios5 the call to [persistentStoreCoordinator_ addPersistentStoreWithType:NSSQLiteStoreType configuration:nil URL:storeURL options:options error:&error] crashes the app saying bad access.
is there any bug documented regarding migration in ios 5 or has anything changed regarding automatic migration?
I cant get any more info on the specifics of the crash hence my question is quite general, but was just wondering if anyone else has experienced difficulties migrating with ios5?
Seems to be a bug in CoreData. Creating a MappingModel and using this options solved the problem for me:
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], NSMigratePersistentStoresAutomaticallyOption,nil];
I am not sure about what has changed, but in general EXC_BAD_ACCESS errors are usually caused when you try to send a message to a released object.
refer Break on EXC_BAD_ACCESS in XCode?

Is there anything that would cause MonoTouch to not generate crash reports?

Is there anything that would cause MonoTouch to not generate crash reports when the app crashes or should it always generate one without fail? ('cause mine is failing)
In my project I hard coded it to throw a NullRefException on a certain action. I would expect to see a crash report written to the Device Logs in XCode but I am not seeing any report generated.
The Console outputs a managed stack trace of where the exception is being thrown though.
You might be wondering why I would want a crash report if I can see it in the console? Well, I want to make sure that crash reports are being generated on test devices and on production builds.
Update: I noticed that upgrading MT from 3.2.6 to 4.0.1 will allow my app to generate crash reports. Unfortunately we're having instability issues with our app running on 4.0.1. Why would 3.2.6 be any different when it comes to crash reporting?
Do you happen to have a top-level exception handler in your "Main" method ?
Something like below? That would keep you from getting a crash report, since it is a clean exit as far as iOS is concerned.
static void Main (string[] args)
{
try {
UIApplication.Main (args);
} catch (Exception e){
Log.ErrorFormat ("Toplevel exception: {0}", e);
}
}
Some reason upgrading to MonoTouch 5 fixed this.

IIS 6/COM+ hangs

I have a web application that sometimes just hangs over heavy load. To make it come back I have to kill the "dllhost.exe" process. Does someone know what to do?
This is an Classic ASP (VBScript) app with lots of COM+ objects.
The server has the following configuration:
Intel Core 2 Duo 2.2 GHz / 4 GB RAM
Windows Server 2003 Web Edition SP2
IIS 6.0
There is some errors in the event log related to the COM objects. But why errors in the COM objects would crash the whole server?
The COM objects are PowerBuilder objects deployed as COM objects.
Is IIS 7.0 (much) more stable than IIS 6.0?
Sounds like dodgy COM objects causing the problem .. do you load them into the "Application", if you do then are they threadsafe; or are they used and discarded on each request?
Yes, recycling every few hours would help 'hide' the problem, but they ought to be debugged and fixed properly ... have you tried divide/conquer to discover which COM object is the problem ... I can imagine this is tricky on a production environment so you need to set up some heavy automated tests to reproduce the problem locally then you can do something about it.
You have a memory leak :)
This blog entry is my bible for IIS troubleshooting:
http://blogs.msdn.com/david.wang/archive/2005/12/31/HOWTO_Basics_of_IIS6_Troubleshooting.aspx
If you can't audit your code and find where the reference leaks are, an alternative is to recycle the application by restarting IIS every 24 hours or so. You can just setup a commandline script as a server job to do this.
There is probably some errors in your eventlog under the Application and System categories. Try to find the origin of these errors or post them here we'll see what we can do :)
Edit :
#Daniel Silveira
A memory leak is probable. What COM+ object do you use? I had some issues with Excel with an application I support.

Resources