I am creating a program that records and plays audio using AudioUnit, but I encountered the following bugs:I tried everything I could, but it didn't improve at all, so I would like to ask you a question.
It appears that there is a memory leak in the middle of the callback function AURenderCallback
configured on the recording side AURenderCallbackStruct.(Allocations
in instruments
is going up and down: 2.5KB/sec)
This is ↓ after a lot of research.
AudioProcessor*rec
, OSStatus
line does not change the symptomAllocations
becomes constant immediately after you delete NSMutableData*dataNSMutableData*data
to int
or NSData
, NSArray
, the Allocation
becomes constant immediately.NSMutableData, NSMutableArray
, and NSObject
do not keep Allocation
going up and downOSStatus AURenderCallback (void* inRefCon,
AudioUnitRenderActionFlags*ioActionFlags,
constAudioTimeStamp* inTimeStamp,
UInt32 inBusNumber,
UInt32 inNumberFrames,
AudioBufferList*ioData)
{
AudioProcessor*rec=(__bridge AudioProcessor*) inRefCon;
OSSStatus status=AudioUnitRender([recaudioUnit], ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, & testbufferList);
NSMutableData*data=[NSMutableData alloc] init];
/*
~ (omitted)
*/
return noErr;
}
Please let me know the above.
objective-c iphone
I know the AudioUnit of Mac in my own way, but the Objective-C
I am not familiar with memory management systems.
In , this source has a seemingly leaky implementation.
Since alloc is a method for securing memory,
every time it is called
It secures the memory, but it doesn't seem to be open.
AURenderCallback runs quite often, so
You can imagine that memory usage will increase just by looking at the source.
In the first place,
Memory retention processing within AURENDERCallback is performed.
It's not a very good strategy, so you can use NSMutableData* data in AURENDERCallback.
We recommend that you modify the action so that does not alloc.
I think there are many ways to do it, but if I were you, I would be given it as an argument for AURENDERCallback
Alloc on the AudioProcessor side and implement for AURenderCallback.
I don't know what's going on with the rest of the AURENDERCallback from this source, so
I will not write a specific source, but I will not be able to process memory retention within AURENDERCallback.
It is often better to write a program as a prerequisite.
© 2024 OneMinuteCode. All rights reserved.