几何尺寸与公差论坛

 找回密码
 注册
查看: 749|回复: 0

【转帖】disconnect from solidworks

[复制链接]
发表于 2009-4-12 17:59:58 | 显示全部楼层 |阅读模式
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.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 18:53 , Processed in 0.034978 second(s), 20 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表