Created
November 8, 2012 22:04
-
-
Save projectgus/4042035 to your computer and use it in GitHub Desktop.
Demonstration of pv reference leak
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import epics,gc | |
name1 = "c1v0:UPTIME" | |
name2 = "c2v0:UPTIME" | |
name3 = "c3v0:UPTIME" | |
def report_usage(): | |
epics.ca.show_cache() | |
# use the gc's debugging features to look for leaked PV objects | |
gc.collect() | |
print("Live PV object count: %d" % len([o for o in gc.get_objects() if type(o) == epics.PV])) | |
print("") | |
def do_some_stuff(): | |
p = epics.PV(name1) | |
p = epics.PV(name2) | |
p = epics.PV(name3) | |
p = None | |
report_usage() | |
do_some_stuff() | |
do_some_stuff() | |
do_some_stuff() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PVName ChannelID/Context Connected? | |
#-------------------------------------------- | |
c2v0:UPTIME c_long(47668984)/47633616 False | |
c1v0:UPTIME c_long(47668928)/47633616 False | |
c3v0:UPTIME c_long(47669040)/47633616 False | |
Live PV object count: 3 | |
# PVName ChannelID/Context Connected? | |
#-------------------------------------------- | |
c2v0:UPTIME c_long(47668984)/47633616 False | |
c1v0:UPTIME c_long(47668928)/47633616 False | |
c3v0:UPTIME c_long(47669040)/47633616 False | |
Live PV object count: 6 | |
# PVName ChannelID/Context Connected? | |
#-------------------------------------------- | |
c2v0:UPTIME c_long(47668984)/47633616 False | |
c1v0:UPTIME c_long(47668928)/47633616 False | |
c3v0:UPTIME c_long(47669040)/47633616 False | |
Live PV object count: 9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# PVName ChannelID/Context Connected? | |
#-------------------------------------------- | |
c2v0:UPTIME c_long(31308984)/31271728 False | |
c1v0:UPTIME c_long(31308928)/31271728 False | |
c3v0:UPTIME c_long(31309040)/31271728 False | |
Live PV object count: 0 | |
# PVName ChannelID/Context Connected? | |
#-------------------------------------------- | |
c2v0:UPTIME c_long(31308984)/31271728 False | |
c1v0:UPTIME c_long(31308928)/31271728 False | |
c3v0:UPTIME c_long(31309040)/31271728 False | |
Live PV object count: 0 | |
# PVName ChannelID/Context Connected? | |
#-------------------------------------------- | |
c2v0:UPTIME c_long(31308984)/31271728 False | |
c1v0:UPTIME c_long(31308928)/31271728 False | |
c3v0:UPTIME c_long(31309040)/31271728 False | |
Live PV object count: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment