当前位置: 首页 > news >正文

做网站的宽度为多少郑州论坛官网

做网站的宽度为多少,郑州论坛官网,中山seo排名优化,石家庄免费建站模板在iphone开发过程中#xff0c;代码中的内存泄露我们很容易用内存检测工具leaks 检测出来#xff0c;并一一改之#xff0c;但有些是因为ios 的缺陷和用法上的错误#xff0c;leaks 检测工具并不能检测出来#xff0c;你只会看到大量的内存被使用#xff0c;最后收到didR…在iphone开发过程中代码中的内存泄露我们很容易用内存检测工具leaks 检测出来并一一改之但有些是因为ios 的缺陷和用法上的错误leaks 检测工具并不能检测出来你只会看到大量的内存被使用最后收到didReceiveMemoryWarning最终导致程序崩溃。以下是开发过程中遇到的一些问题和网上的一些资料总结了一下   一、[UIImage imageNamed:]只适合与UI界面中的贴图的读取较大的资源文件应该尽量避免使用 用UIImage加载本地图像最常用的是下面三种 1.用imageNamed方法 [UIImage imageNamed:ImageName]; 2.用 imageWithContentsOfFile 方法 NSString *thumbnailFile [NSString stringWithFormat:%/%.png, [[NSBundle mainBundle] resourcePath], fileName]; UIImage *thumbnail [UIImage imageWithContentsOfFile:thumbnailFile]; 3. 用initWithContentsFile方法 UIImage *image [[UIImage alloc] initWithContentsOfFile:filePath]   第一种方法为常见方法利用它可以方便加载资源图片。用imageNamed的方式加载时会把图像数据根据它的名字缓存在系统内存中以提高imageNamed方法获得相同图片的image对象的性能。即使生成的对象被 autoReleasePool释放了这份缓存也不释放。而且没有明确的释放方法。如果图像比较大或者图像比较多用这种方式会消耗很大的内存。 第二种方法加载的图片是不会缓存的。得到的对象时autoRelease的当autoReleasePool释放时才释放。 第三种方法要手动release掉。不系统缓存。release后立即释放一般用在封面等图比较大的地方。   二、 滑动列表的时候使用UITableView的reuse机制 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier Cell; UITableViewCell *cell [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell nil) { cell [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; }   dequeueReusableCellWithIdentifier 方法会把隐藏的界面拿来重用这样节省很多资源。   三、要大量创建局部变量的时候可以创建内嵌的autorelease pool来及时释放内存 int main (int argc, const char *argv[]) { NSAutoreleasePool *pool [[NSAutoreleasePool alloc] init]; int i, j; for (i 0; i 100; i ) {NSAutoreleasePool *loopPool [[NSAutoreleasePool alloc] init];for (j 0; j 100000; j )[NSString stringWithFormat:1234567890];//产生的对象是autorelease的。[loopPool release]; } [pool release]; return (0); } // main   详细查看iPhone/Mac Objective-C内存管理教程和原理剖析(一)基本原理 四、频繁打开和关闭SQLite导致内存不断的增长 SQLite的数据库本质上来讲就是一个磁盘上的文件频繁打开和关闭是很耗时和浪费资源的可以设置SQLite的长连接方式避免频繁的打开和关闭数据库   五、在UITableView 的cellForRowAtIndexPath 代理中不要使用 stringWithFormat 方法 定义一个字符串变量有很多方法最简单的就是 NSString *str “abc” 还有initWithString、stringWithFormat和stringWithCString等等。大量的字符操作时不同的方法消耗不同的内存。 以下测试代码转自http://www.cocoachina.com/bbs/read.php?tid-17652-fpage-9.html //测试机器 2.4 GHz Intel Core 2Duo    2GB 667 MHz DDR2   GCC 4.2- (void)testStringSpeed:(id)sender {NSAutoreleasePool *pool[[NSAutoreleasePool alloc] init];[textField setStringValue:];int testi,testnum10;float c,tm0.0;for(testi0;testitestnum;testi){NSDate *beg[NSDate date];int i,n10000000;for(i0;in;i){//avg0.030204/*{//avg0.594266 内存基本稳定不变NSString *t[[NSString alloc] initWithString:abccc];[t release];}*//*{//avg0.026101 内存基本稳定不变NSString *astring abcc;}*//*{//avg0.278873 内存基本稳定不变NSString *astring [[NSString alloc] init];astring abcc;[astring release];}*//*{//avg2.737541 内存基本稳定不变char *Cstring abcc;NSString *astring [[NSString alloc] initWithCString:Cstring];[astring release];}*//*{//avg3.619728 内存增长过快NSString *a[NSString stringWithString:abcc];}*//*{//太长时间内存增长过快NSString *a[NSString stringWithFormat:abcc%d,i];}*//*{//avg0.034632 内存基本稳定不变char a[]abcc;}*//*{//18.1555 内存稍有增长NSString *a[[NSString alloc] initWithFormat:abcc%d,i];[a release];}*//*{//avg2.276076 内存基本稳定不变char a[32];sprintf(a,abcc%d,i);}*//*{//太长时间内存增长过快NSMutableString *a[[NSMutableString alloc] init];[a stringByAppendingFormat:abcc%d,i];[a release];}*/}c[[NSDate date] timeIntervalSinceDate:beg];tmc;[textField setStringValue:[NSString stringWithFormat:%\n%d%f,[textField stringValue],testi1,c]];}[textField setStringValue:[NSString stringWithFormat:%\navg%f,[textField stringValue],(float)tm/testnum]];[pool release]; }   由于stringWithFormat 即耗时又耗内存所以在cellForRowAtIndexPath 绘制cell 的时消耗大量内存和时间造成界面滑动不流畅。   六、关于 colorWithPatternImage 的内存泄露 self.view.backgroundColor [UIColor colorWithPatternImage:[UIImage imageNamed:bg.png]]; 此方法用图片来设置view的背景颜色但是某些设备上会导致内存泄露详细查看 http://blog.csdn.net/cococoolwhj/article/details/6942981 http://www.cocoaintheshell.com/2011/01/colorwithpatternimage-memory-usage/  转载于:https://www.cnblogs.com/zeejun/archive/2012/05/08/2485535.html
http://www.pierceye.com/news/461602/

相关文章:

  • 确定网站的主题与风格东营市建设项目工伤保险是哪个网站
  • 如何做一张网站平面效果图装宽带需要多少钱
  • 什么网站能让小孩做算术题厦门住房和城乡建设局网站
  • 网站上线过程建设网站什么费用
  • 企业网站域名在哪申请成都广告公司
  • 手机页面网站模板怎么卖宁波网站建设优化找哪家
  • 深圳网站外包公司注册公司流程和费用找哪家
  • 专业新站整站快速排名公司商业网站和企业网站的区别
  • 网站做等保备案河北建设厅网站登陆怎么找附件
  • 网站前台显示数据库指定分类怎么做php优化大师官方免费
  • 用ps软件做ppt模板下载网站c2c网站开发策划
  • 标志空间 网站tk域名网站多少
  • dedecms网站地图插件永康公司网站开发
  • 比较网站建设有没有学做ppt发网站或论坛
  • 用asp做网站流程做科研找论文的网站
  • 新浪网站怎么做推广广告网站模板下载不了
  • 微网站建设哪家优惠h5小游戏在线玩
  • 娄底高端网站建设网站建设费计入 科目
  • 免费企业网站程序上传wordpress 卸载
  • 大庆市建设局网站上不去linux删除WordPress
  • 宣城市建设监督管理局网站下载怎么上wordpress
  • 福州做网站fjfzwl编写软件开发文档
  • 平台设计网站公司电话号码建站哪家好用兴田德润
  • 宝安网站建设信科免费网站开发 自动填写表单
  • 网站怎么更新文章动漫网站在线免费观看
  • 织梦 网站迁移网页制作三剑客通常指
  • 南京本地网站建站武安百度seo
  • 特定ip段访问网站代码西安免费建网站设计
  • 个人网站备案取消wordpress可以做大吗
  • 如何做网站管理网站服务器基本配置