| 发表于:2008-01-17 17:25:22 楼主 |
vb理论上不会出现内存泄漏问题,但是在处理一些大的循环时,会涉及到变量,特别是对象内存的释放。 一般的说法时,对象在没有引用后会自动销毁,但是这个销毁是在什么时间?是过程内?还是依赖编译时生成的变量引用周期表?或者程序结束? 我现在有一个数据库小程序,大概要处理数百万跳记录,核心代码大致如下 dim orstsource,orsttarget dim ore,omatches,omatch orstsource.open "select * from tablea",oconn,3,3 orsttarget.open "select * from tableb",oconn,3,3 set oreg=new reexp ore.ignorecase=true:ore.global=true ore.pattern="略" do while not orstsource.eof set omatches=ore.excute(orstsource("xx")) for each omatch in omatches orsttarget.addnew ........proc omatch.....产生数百跳结果存入orsttarget orsttarget.update next '注意,这里没有set omatches,omatch=nothing,而是在loop后面 orstsource.movenext loop set omatches=nothing set omatch=nothing 问题: 1、这个omatch在重新赋值时,前面的对象内存是立即销毁了吗?? 2、我在实际使用这个程序时,内存不断上升,是由于数据库的原因,还是在loop中对象没有setnothing的原因 orstsouce有5万条,平均每条会在orsttarget产生100-200条新记录,总数非常庞大,处理了半天,只到10%,内存不断攀升,数据库是access。 |
|
|
|
|