- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
更新:我认为问题是内存不足;它不是。此错误在 4.3 中始终发生,而在 4.1/4.2 中即使在内存非常低的情况下也不会发生。
这是在一个小型 Objective-C 库中,我必须为主要是 Monotouch 应用程序编写——AVFoundation 尚未完全绑定(bind)。
这是跟踪:
0 Orbiter 0x007977d8 mono_handle_native_sigsegv + 404
1 Orbiter 0x007746b4 mono_sigsegv_signal_handler + 348
2 libsystem_c.dylib 0x34ce472f _sigtramp + 42
3 AVFoundation 0x365b3ab5 -[AVAssetExportSession dealloc] + 164
4 CoreFoundation 0x34bc2c43 -[NSObject(NSObject) release] + 30
5 AVFoundation 0x365b3607 -[AVAssetExportSession release] + 62
6 CoreFoundation 0x34bdd047 sendRelease + 14
7 libsystem_blocks.dylib 0x312c292f _Block_object_dispose + 118
8 AVFoundation 0x365b45b3 __destroy_helper_block_5 + 22
9 libsystem_blocks.dylib 0x312c288f _Block_release + 58
10 libdispatch.dylib 0x30df18ed _dispatch_call_block_and_release + 16
11 libdispatch.dylib 0x30deced1 _dispatch_queue_drain + 240
12 libdispatch.dylib 0x30ded043 _dispatch_queue_invoke + 78
13 libdispatch.dylib 0x30dec611 _dispatch_worker_thread2 + 196
14 libsystem_c.dylib 0x34cda591 _pthread_wqthread + 264
15 libsystem_c.dylib 0x34cdabc4 _init_cpu_capabilities + 4294967295
代码如下:
@implementation AVUtils : NSObject
+ (void) dubAudio:(NSURL*)videoUrl
withTrack:(NSURL*)audioUrl
outputTo:(NSURL*)newUrl
handleSuccess:(void(^)(void))successHandler
handleFailure:(void(^)(NSError* err))failureHandler
{
AVURLAsset* video = [[AVURLAsset alloc]initWithURL:videoUrl options:nil];
AVAssetTrack* videoTrack = [[video tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
CMTime videoDuration = video.duration;
AVURLAsset* audio = [[AVURLAsset alloc]initWithURL:audioUrl options:nil];
AVAssetTrack* audioTrack = [[audio tracksWithMediaType:AVMediaTypeAudio] objectAtIndex:0];
CMTime audioDuration = audio.duration;
CMTime newDuration = CMTimeMinimum(audioDuration, videoDuration);
CMTimeRange newTimeRange = CMTimeRangeMake(kCMTimeZero, newDuration);
AVMutableComposition* newComposition = [AVMutableComposition composition];
NSError* theError;
BOOL success;
AVMutableCompositionTrack* newAudioTrack = [newComposition addMutableTrackWithMediaType:AVMediaTypeAudio
preferredTrackID:kCMPersistentTrackID_Invalid];
theError = nil;
success = [newAudioTrack insertTimeRange:newTimeRange ofTrack:audioTrack atTime:kCMTimeZero error:&theError];
if (success == NO) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error adding audio track"
message:[theError localizedDescription]
delegate: nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alertView show];
[alertView release];
} else {
AVMutableCompositionTrack* newVideoTrack = [newComposition addMutableTrackWithMediaType:AVMediaTypeVideo
preferredTrackID:kCMPersistentTrackID_Invalid];
theError = nil;
success = [newVideoTrack insertTimeRange:newTimeRange ofTrack:videoTrack atTime:kCMTimeZero error:&theError];
if (success == NO) {
UIAlertView* alertView = [[UIAlertView alloc] initWithTitle:@"Error adding audio track"
message:[theError localizedDescription]
delegate: nil
cancelButtonTitle:@"Cancel"
otherButtonTitles:nil];
[alertView show];
[alertView release];
} else {
AVAssetExportSession* _assetExport = [[AVAssetExportSession alloc] initWithAsset:newComposition presetName:AVAssetExportPresetPassthrough];
_assetExport.outputFileType = @"com.apple.quicktime-movie";
_assetExport.outputURL = newUrl;
_assetExport.shouldOptimizeForNetworkUse = YES;
[_assetExport exportAsynchronouslyWithCompletionHandler:
^(void) {
if (_assetExport.status == AVAssetExportSessionStatusCompleted) {
successHandler();
} else {
failureHandler(_assetExport.error);
}
[_assetExport release];
[video release];
[audio release];
[newComposition release];
}
];
}
}
}
@end
我的理论是,我泄漏了指向 _assetExport.error
的指针,将其传递给另一个线程(我就是这样),然后在取消引用时它无效,因为 _assetExport
正在被垃圾收集。但我验证了即使导出成功也会发生段错误,所以在本例中不是这样。
我对 Obj-C 还很陌生——任何人都可以看到我在这里所做的任何其他明显的缺陷吗?
最佳答案
看起来与完成 block 有关的内存管理是问题所在。崩溃日志表明它在释放 _assetExport 时崩溃。您绝对不应该释放 newComposition (您没有分配或保留它)。
关于iphone - AVAssetExportSession dealloc 在 iOS 4.3 中崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5346382/
演讲的主题是 Objective-c 中的类和对象。我无法理解 [super dealloc] 的概念。我们有一些类 myClass,它继承自 NSObject。它有一些方法并从父类继承其他方法。所以
对于 ARC,有时我仍然需要编写一个 -dealloc 方法来进行一些清理。在极少数情况下,我需要引用实例的属性才能正确进行清理。例如从 NSNotificationCenter 中注销给定的发送者对
如果我有一个由 View Controller 控制的 View 堆栈,并且当我从 View 堆栈中弹出 View 时调用了 View 的 dealloc(包含 [super dealloc] )方法
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 9 年前。 Improve
当我的应用程序开始在我的自定义注释方法中崩溃时,我了解到我的内存有问题。我确信管理 map 的 viewcontroller 100% 应该已经从 View 堆栈中弹出。 这里是注释的代码,TaxiA
我刚刚一直在阅读有关如何正确地在 init 方法中失败的信息,并且文档似乎彼此不同意。一个建议抛出异常,而其他建议清理并返回 nil。当前的最佳做法是什么? 最佳答案 我相信普遍接受的做法是在失败时返
这是我的情况。这很复杂,所以请耐心等待。 我有一个 View 类,我们称它为 MyView。它创建一个加载指示器 subview ,然后启动将加载数据的后台操作。它还创建了一个 block ,后台队列
我正在设置 AMScrollingNavbar在 swift 。当我尝试转换时 - (void)dealloc { [self stopFollowingScrollView]; } 到 func
我正在尝试执行以下操作: 获得类'dealloc IMP 向所述类中注入(inject)一个自定义 IMP,它基本上调用原始的 dealloc IMP 当所述类的一个实例被释放时,两个 IMP 都应该
在我的一个 View Controller 中,它将自身添加为 UITextViewTextDidEndEditingNotification 通知的观察者,如下所示 [[NSNotification
我正在初始化一个对象,然后内联配置它。但是,不是在配置前一个实例(如果之前已分配)之前将其释放(在紧随其后的行中),而是推迟释放。因此,我对它所做的所有配置最终都成为一个已释放的对象 - 这当然不是我
是否需要将所有声明为IBOutlet的带有retain修饰符的@property设置为nil - (void)dealloc 方法?如果我不这样做,内存会被消耗/浪费吗? 假设自动引用计数关闭。 最佳
这是我在应用程序中切换 View 的方式: CGRect frame = self.view.frame; frame.origin.x = CGRectGetMaxX(frame);
假设有一个带有两个选项卡 A 和 B 的选项卡栏 Controller ,其中 A 是导航 Controller 。 当用户在A中时,他可以推送A1,然后推送A2,它们都是 View Controll
我有一个加载两个 View Controller 的 Root View 。例如:FirstVC、SecondVC。 当应用程序启动时,我将 FirstVC 显示为 Root View Control
我有一个基于导航的应用程序,可以在一些 ViewController 之间切换。如果我按下“goHome”按钮,方法 popViewControllerAnimated: 被调用,然后我返回到主屏幕。
我正在尝试调试为什么我的 dealloc 覆盖没有在我的一个 View Controller 上被调用。 我有一个通过 Storyboard设置的 View Controller 。我已经重写了所有
对于我的 iOS 7 应用,只想确认: dealloc 是否仍会被调用? 与是否开启ARC有关系吗? 最佳答案 是的,无论您是否使用 ARC,dealloc 都会在对象被释放时调用。 但是请注意,当您
我很难适应 C++ 处理动态和自动内存的方式。 我的问题: 指向自动分配实例的指针是否可以保留该实例解除分配,即使实例化范围已离开? 在this帖子我读到所有指向 dealloc 内存的指针都是无效的
我有三个 UIViewControllers,每当我关闭它们时,它们的所有 dealloc 方法都会被调用。这正是我想要发生的事情,这样内存就不会膨胀。 但是,当我运行配置文件来测试内存使用情况和一些
我是一名优秀的程序员,十分优秀!