几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量  


返回   几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 » 仿射空间:CAX软件开发(三)二次开发与程序设计 » CAD二次开发 » SolidWorks二次开发
用户名
密码
注册 帮助 会员 日历 银行 搜索 今日新帖 标记论坛为已读


 
 
主题工具 搜索本主题 显示模式
旧 2009-04-12, 05:59 PM   #1
yang686526
高级会员
 
注册日期: 06-11
帖子: 14579
精华: 1
现金: 224494 标准币
资产: 234494 标准币
yang686526 向着好的方向发展
默认 【转帖】disconnect from solidworks

disconnect from solidworks
i have a large program that i execute on my assembly. this program traverses the tree, populates quantities, manages properties and so on...
i execute the program the first time i open solidworks and it runs extremely fast. if i try to run the program again, it is very slow. i think the problem is that my program is not releasing solidworks when it is done. when i close solidworks, you can still see sldworks.exe running in the task manager. if i don't use my program and close solidworks, this does not happen.
i guess my question is how do you "release" solidworks when you are done with your program.
i have tried the typical:
swapp = nothing
thanks in advance!
tony szuta
cswa, cswp, cswp-smtl
it will not be that you are not releasing solidworks, it is a classic garbage collection issue. you are not releasing your variables correctly to be collected by gc and so if you look in task manager as your program runs you will see it gather more and more memory in the mem usage column. check that and let me know if it is the case, if so we can go from there
answer luke,
there were a few variables that i did not release at all. this was the problem. now i run my program and it works perfect every time.
thanks.
tony szuta
cswa, cswp, cswp-smtl
pretty new programmer here and learning by trail by fire...
how do you release variables.
as i write larger and larger programs i see this becoming a problem.
currently i am in the same boat. i can run it once or twice and then need to reset my memory by restarting my computer, lol
edit: do i need to release every single variable in the program (ie strings, ints ect) or just objects like swapp and swdrawingdoc?
edited: 03/20/2009 at 11:25 am by kevin hardin
set [yourvariablename] = nothing
i'll get you eh steve, if it's the last thing i dooooo!
i found this the other day about releasing com objects.
you technically do not need to release any in .net as the garbage collection will periodically scan for invalid pointers (dead or invalid variables/properties etc...) and the gc will release them for you. however it is not recommended to leave it all up to the gc as it is unpredictable. your best bet is to free up any variables once you are finished with them, and then called gc.collect if you want to force .net to free up the memory instantly.
strings, bool, char, doubles etc... are all simple variables and no not need releasing. objects on the other hand all do (anything with a structure, classes, interfaces, data objects, com objects etc..), and is done by setting them to null or calling there dispose property if that are inhereted from the idisposable interface.
yang686526离线中   回复时引用此帖
GDT自动化论坛(仅游客可见)
 


主题工具 搜索本主题
搜索本主题:

高级搜索
显示模式

发帖规则
不可以发表新主题
不可以回复主题
不可以上传附件
不可以编辑您的帖子

vB 代码开启
[IMG]代码开启
HTML代码关闭



所有的时间均为北京时间。 现在的时间是 04:23 PM.


于2004年创办,几何尺寸与公差论坛"致力于产品几何量公差标准GD&T | GPS研究/CAD设计/CAM加工/CMM测量"。免责声明:论坛严禁发布色情反动言论及有关违反国家法律法规内容!情节严重者提供其IP,并配合相关部门进行严厉查处,若內容有涉及侵权,请立即联系我们QQ:44671734。注:此论坛须管理员验证方可发帖。
沪ICP备06057009号-2
更多