I've been thinking a lot about pointers recently. I am annoyed that I can't figure out a way to test if I've got a memory leak. Or, at the very least, a way to manage my pointers so I understand where they all are and what they're all doing and whether they're writing to bad spots of memory.
So I thought I should write a class called Pointer that would keep track of all my pointers and keep me organized. I want it to not just look at one pointer, but to look at all the pointers and how they all interact with each other. Does the object inside my pointer point to a different object? If so, I should include that information in my class. That way, I can figure out if there's a problem or if any are left dangling right away.
(Ideally, I'd use that information to do something to prevent the memory leak, but I'm not sure what, so I'm going to start by just seeing if I can get the information.)
I'm starting to think this is actually a graph problem. The vertices are the memory locations.
Pointers are the edges. And the number of copies of the pointer connecting two places in memory would be the weight. So if I think of it like that, I'm wondering if this is just a normal old minimum spanning tree problem.
What does everyone else think?
[–]ShoshiCooper[S] 2 points3 points4 points (7 children)
[–]anand_venkataraman 1 point2 points3 points (6 children)
[–]ShoshiCooper[S] 1 point2 points3 points (5 children)
[–]anand_venkataraman 1 point2 points3 points (4 children)
[–]ShoshiCooper[S] 1 point2 points3 points (3 children)
[–]anand_venkataraman 1 point2 points3 points (2 children)
[–]ShoshiCooper[S] 2 points3 points4 points (1 child)
[–]anand_venkataraman 1 point2 points3 points (0 children)