McGillivray, Don [IT]
Donald.A.McGillivray at sprint.com
Thu Jan 22 12:38:58 CST 2009
Hi, All I'm looking for guidance on identifying the source of a memory leak in an application. I've already gone through my code to ensure that each "Set ObjVariable = . . . " statement is accompanied by a "Set ObjVariable = Nothing" statement. All my procedures use error handling, and are forced to exit through a substructure that contains the proc's "Set ObjVariable = Nothing" statements, ensuring that the object variables are set to nothing even when an error occurs. As the app runs, both memory usage and the handle count slowly creep up over time - the handle count faster than the memory usage. I did a simple experiment by monitoring handle usage while opening and closing a single table in a database several times. I noticed that at first the handle usage was variable, but that after several repetitions it more or less stabilized. Something like this: Rep State Handles ================================= 0 Initial 195 1 Open 203 1 Closed 199 2 Open 203 2 Closed 200 3 Open 202 3 Closed 200 4 Open 201 4 Closed 200 5 Open 210 5 Closed 204 6 Open 207 6 Closed 204 7 Open 206 7 Closed 201 8 Open 204 8 Closed 201 9 Open 204 9 Closed 201 For grins, I left the db open and idle overnight. When I checked this morning, its memory usage had gone from 20.7 MB to 3.7 MB. Upon opening the table, the usage went to 7.8 MB and stayed around there after several open/close repetitions. So, now I'm more confused than when I started. How exactly does one detect memory leak, and once detected, how to find its source? Anybody out there with nothing better to do than to educate my weak brain? Don This e-mail may contain Sprint Nextel Company proprietary information intended for the sole use of the recipient(s). Any use by others is prohibited. If you are not the intended recipient, please contact the sender and delete all copies of the message.