请教一个内存条出问题的表现管理中的问题

2004年3月 C/C++大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。新手请教一下内存管理问题!【unity3d吧】_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:74,942贴子:
新手请教一下内存管理问题!收藏
虽然已经懂得写一些小逻辑了,但对优化这方面还是一头雾水,网上经验贴感觉好抽象。完全听不懂!有好几个问题想请教一下instantiate()和destroy()函数的调用是不是很耗cpu性能? 不适合频繁调用?据说destroy()函数在销毁了对象后,并不会立刻释放内存,这是为什么?有人却说当销毁一个对象时,假如对象是个克隆体,会释放克隆体的所占用的内存,但不会释放预制件prefab的内存。究竟哪个是真的?现在有点纠结:到底是预先创建几个对象,当要时激活,不需要时取消激活。避免频繁调用instantiate 和 destroy 。还是直接使用这些函数。我想实现在场景中显示物体的UI提示。当接近时显示ui,当远离时屏蔽。但 UI的数量不确定 ,所以想到能否使用以上那些函数。AssetBundle是加载预制件的类吗?它和resource的区别在哪里?官方建议使用AssetBundle以上就是那么多问题了,想到了再补充…请各位帮帮忙,教教我。谢谢!
娜迦APP加固服务具有:防逆向,篡改保护; 防调试,恶意代码植入;防反编译和环境监测
刚学会,你离这些问题还远。
第一个问题,实例化和删除该用还得用。他们说的对象池的意思是可以重复用的东西,比如雷电游戏里的子弹,你消耗了就存起来,不要用一个生成一个删除一个。
关于加载内存,我以assetbundle为例,你可以这么想,要把一个包着包裹的快递取出来。第一步,你要把包裹拿起来(把assetbundle加载进内存),第二步拆包裹(解ab的包),第三步把东西取出来(实例化物体)。到目前为止,你在这个空间中,物体占了空间,同时你的包裹也占用着空间。假如你后面什么都不做,空间里就会存在两个包裹大小的内存,当然你也可以选择把装包裹的ab卸载了,毕竟你东西已经取出来了。
关于加载方式和区别,resource等等其他加载方法是需要你把东西都弄好放在安装包里,想要用什么取什么,毕竟你已经都打进去了。但是,这时候安装包会很大,玩家不乐意了,太大不下。这时候你可以把你的一部分模型取出来,放在服务器上下载到本地再用。这时候那些个加载方式都不能用了,为什么?因为你想啊,要是这个程序成型了,还能随便往里面塞东西,那多不安全。所以就另外给你个地方,你要加载东西也可以,你得放外面,你用的时候再取进来。这时候他就可以限制,你只能取一些模样啊动画啊贴图啊等等东西进来,你的代码进不来。这样就能保障了程序安全。
关于你ui激活不激活,很简单,靠近的时候判断下,你的ui有没有,如果需要,但是没有,那就实例化出来一个,之后如果经常要用到开关,那就用开关做,别删了。对于那些不常用的ui或者基本就用一两次的,该删删好了。
登录百度帐号推荐应用2013年4月 硬件/嵌入开发大版内专家分月排行榜第二2007年9月 硬件/嵌入开发大版内专家分月排行榜第二
2013年5月 硬件/嵌入开发大版内专家分月排行榜第三2012年9月 硬件/嵌入开发大版内专家分月排行榜第三2007年11月 硬件/嵌入开发大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。查看: 361|回复: 3|关注: 0
请教批量读取excel过程中内存管理的问题以及解决办法
<h1 style="color:# 麦片财富积分
新手, 积分 20, 距离下一级还需 30 积分
本帖最后由 qiuhuizuo 于
15:12 编辑
操作系统xp 32位,cpu i5&&,内存4G,matlab版本R2010b,excel 2007 。目前使用matlab批量读取2000+ excel文件。文件全部放在同一个文件夹下。读取到1927时程序中断并产生报错信息。附件中是任务管理器的截图。下方是程序代码以及报错代码。请高手看看是什么问题,如何解决?十分感谢!
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
function [b c xlsstr xlsdata] =inputexcel(k)
%根据给出的地址,将文件夹中的excel文件全部录入到指定的mat文件中
path=k;%根据给出的地址将默认目录跳转到对应的地址
%
%
prxlsstr={};%定义存放利润表excel文字的cell
prxlsdata={};%定义存放利润表excel数据的cell
prxlsall={}; %定义存放利润表excel全部内容的cell
blxlsstr={};%定义存放资产负债表excel文字的cell
blxlsdata={};%定义存放资产负债表excel数据的cell
blxlsall={}; %定义存放资产负债表excel全部内容的cell
bijiao=strfind(path,'Profit') %如果地址中包含profit,则数据保存在profitsamp.mat中
if bijiao&1
a=dir(path);& && &&&%读入目录下文件信息存储为结构体形式
prb=struct2cell(a); %将格式转为cell形式
prb(:,1:2) = [];& & %将b结构体第一列和第二列所有行都设为空。因为这些是根目录内容
prc=prb(1,:);& && &&&%取出其中文件名单元
[h,l]=size(prc);& &%计算文件个数
jj=0;& && && && & %循环计数数值初始化
for ii=1:l
file_address=strcat(path,prc{ii});
if strfind(prc{ii},'.xls')& & %如果是xls文件格式 根据c的数据结构从第一个数据开始检查该文件是否是xls格式,如果不是就跳出本次循环进入下一循环
jj=jj+1;& && && && && && &&&%如果该是xls文件格式,计数器加1 。
[prxlsdata{jj},prxlsstr{jj},prxlsall{jj}]=xlsread(file_address); %同时读取c1所对应的excel文件,将文本数据和数字数据分别存放
jj
system('taskkill /F /IM EXCEL.EXE')
end
end
& &save profitsamp prb prc prxlsstr prxlsdata prxlsall
end
bijiao=strfind(path,'Banlanc')&&%如果地址中包含Banlanc,则数据保存在Banlancsamp.mat中
if bijiao&1
& & a=dir(path);& && &&&%读入目录下文件信息存储为结构体形式
& & blb=struct2cell(a); %将格式转为cell形式
& & blb(:,1:2) = [];& & %将b结构体第一列和第二列所有行都设为空。因为这些是根目录内容
& & blc=blb(1,:);& && &&&%取出其中文件名单元
& & [h,l]=size(blc);& &%计算文件个数
& & jj=0;& && && && & %循环计数数值初始化
for ii=1:l
file_address=strcat(path,blc{ii});
if strfind(blc{ii},'.xls')& & %如果是xls文件格式 根据c的数据结构从第一个数据开始检查该文件是否是xls格式,如果不是就跳出本次循环进入下一循环
jj=jj+1;& && && && && && &&&%如果该是xls文件格式,计数器加1 。
[blxlsdata{jj},blxlsstr{jj},blxlsall{jj}]=xlsread(file_address); %同时读取c1所对应的excel文件,将文本数据和数字数据分别存放
jj
system('taskkill /F /IM EXCEL.EXE')
end
end
& &save Banlancsamp blb blc blxlsstr blxlsdata blxlsall
end复制代码
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
??? Out of memory. Type HELP MEMORY for your options.
Error in ==& xlsread&parse_data
Error in ==& xlsread at 318
& & [data,text] = parse_data(rawData);
Error in ==& inputexcel at 48
[blxlsdata{jj},blxlsstr{jj},blxlsall{jj}]=xlsread(file_address); %同时读取c1所对应的excel文件,将文本数据和数字数据分别存放
Unexpected error status flag encountered.&&Resetting to proper state.
&& help memory
MEMORY Memory information.
& & See 'doc memory' for more information on how to make the
& & best use of memory when running MATLAB.
& & MEMORY when called without an output argument displays
& & information about how much memory is available and how
& & much is currently being used by MATLAB. All values are double
& & precision and in units of bytes.
& & USERVIEW = MEMORY returns information about how much memory is
& & available and how much is currently being used by MATLAB. USERVIEW
& & is a structure that contains the following fields:
& && & MaxPossibleArrayBytes -- The largest contiguous free memory block.
& && && & It is an upper bound on the largest single array that MATLAB can
& && && & currently create. This field is the smaller of these two values:
& && && && & a) The largest contiguous memory block found in the
& && && && && & MATLAB virtual address space, or
& && && && & b) The total available system memory.
& && && & To find the number of elements, divide MaxPossibleArrayBytes
& && && & by the size of each element in bytes. For example, divide by
& && && & eight for a double matrix. The actual number of elements that
& && && & that can be created is always less than this number.
& && & MemAvailableAllArrays -- The total amount of memory available
& && && & for data. This field is the smaller of these two values:
& && && && & a) The total available MATLAB virtual address space, or
& && && && & b) The total available system memory.
& && && & The amount of memory available is guaranteed to be at least
& && && & as large as this field.
& && & MemUsedMATLAB -- The total amount of system memory reserved for the
& && && & MATLAB process. This is the sum of the physical memory and
& && && & potential swap file usage.
& & [USERVIEW, SYSTEMVIEW] = MEMORY returns additional, and more detailed
& & information about the current state of memory usage.&&SYSTEMVIEW is a
& & structure containing the following:
& && & VirtualAddressSpace -- A 2-field structure that contains the
& && && & amount of available memory and the total amount of virtual
& && && & memory for the MATLAB process.
& && & SystemMemory -- A 1-field structure that contains the amount of
& && && & available system memory. This number includes the amount of
& && && & available physical memory and the amount of available swap file
& && && & space on the computer running MATLAB.
& && & PhysicalMemory -- A 2-field structure that contains the amount of
& && && & available physical memory and the total amount of physical memory
& && && & on the computer running MATLAB.&&It can be useful as a measure
& && && & of how much data can be accessed quickly.
& & The MEMORY function is currently available on PCWIN and PCWIN64 only.
& & Results will vary depending on the computer running MATLAB, the load
& & on the computer, and what MATLAB is doing at the time.
& & Example 1: Run the MEMORY command on a 32-bit Windows system:
& && &&&&& memory
& && &&&Maximum possible array:& && && && & 677 MB (7.101e+008 bytes) *
& && &&&Memory available for all arrays:& &1602 MB (1.680e+009 bytes) **
& && &&&Memory used by MATLAB:& && && && &&&327 MB (3.425e+008 bytes)
& && &&&Physical Memory (RAM):& && && && & 3327 MB (3.489e+009 bytes)
& && &&&*&&Limited by contiguous virtual address space available.
& && &&&** Limited by virtual address space available.
& && &&&&&
& & Example 2: Run the MEMORY command on a 64-bit Windows system:
& && &&&&& memory
& && &&&Maximum possible array:& && && && && &4577 MB (4.800e+009 bytes) *
& && &&&Memory available for all arrays:& && &4577 MB (4.800e+009 bytes) *
& && &&&Memory used by MATLAB:& && && && && &&&330 MB (3.458e+008 bytes)
& && &&&Physical Memory (RAM):& && && && && & 3503 MB (3.674e+009 bytes)
& && &&&*&&Limited by System Memory (physical + swap file) available.
& && &&&&&
& & Example 3: Run the MEMORY command with two outputs on a 32-bit Windows
& && && && && &system:
& && &&&&& [uV sV] = memory
& && &&&uV =
& && && && &MaxPossibleArrayBytes:
& && && && &MemAvailableAllArrays: 1.
& && && && && && &&&MemUsedMATLAB:
& && &&&sV =
& && && && &VirtualAddressSpace: [1x1 struct]
& && && && && && & SystemMemory: [1x1 struct]
& && && && && &&&PhysicalMemory: [1x1 struct]
& && &&&&& sV.VirtualAddressSpace
& && &&&ans =
& && && && &Available: 1.
& && && && && & Total: 2.
& && &&&&& sV.SystemMemory
& && &&&ans =
& && && && &Available: 4.
& && &&&&& sV.PhysicalMemory
& && &&&ans =
& && && && &Available: 2.
& && && && && & Total: 3.
& & Reference page in Help browser
& && & doc memory
论坛优秀回答者
<h1 style="color:#6 麦片财富积分
关注者: 34
为什么要全部录入一个mat?这对内存要求很高,matlab也不是无限制可以使用内存的
说说你的目的,可以改算法节约内存使用
<h1 style="color:# 麦片财富积分
这些excel文件总共不超过50M。我录入.mat的目的就是遍历数据,进行数据检索。
<h1 style="color:# 麦片财富积分
请问解决了么?该怎么办呢?
站长推荐 /2
利用MATLAB/Simulink开发智能机器人系统
MATLAB中文论坛是全球最大的 MATLAB & Simulink 中文社区。用户免费注册会员后,即可下载代码,讨论问题,请教资深用户及结识书籍作者。立即注册加入我们吧!
MATLAB官方社交平台
MATLAB中文论坛微社区(dada的蜜糖)
([已注销])
(我爱连绵词(TM))
(线平-新生)
第三方登录:

我要回帖

更多关于 echarts 内存释放问题 的文章

 

随机推荐