Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

address() class use causes memory leak #4

Closed
caffeineinfused opened this issue Apr 18, 2016 · 3 comments
Closed

address() class use causes memory leak #4

caffeineinfused opened this issue Apr 18, 2016 · 3 comments

Comments

@caffeineinfused
Copy link
Collaborator

creating new instances of the address class for passing around addresses causes memory leaks due to used, no-longer-referenced, and not deleted address instances

address class should likely be converted to a static class with static method for convenient address calculations given cache parameters, with no actual instances of address class

@tmsimont
Copy link
Owner

Are you sure about this?

I ran with this trace: https://www.cs.utexas.edu/~fussell/courses/cs352.fall98/Homework/cc1.din.Z and Valgrind doesn't think there are any leaks:

==26852== Memcheck, a memory error detector
==26852== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
==26852== Using Valgrind-3.10.0 and LibVEX; rerun with -h for copyright info
==26852== Command: ./main
==26852==
==26852==
==26852== HEAP SUMMARY:
==26852==     in use at exit: 0 bytes in 0 blocks
==26852==   total heap usage: 24,846 allocs, 24,846 frees, 828,804 bytes allocated
==26852==
==26852== All heap blocks were freed -- no leaks are possible
==26852==
==26852== For counts of detected and suppressed errors, rerun with: -v
==26852== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

@tmsimont
Copy link
Owner

When you pass to a.cacheRead(address(addr)) or a.cacheWrite(address(addr)) you're just passing a copy of a new instance, not a pointer (which would be a.cacheRead(new address(addr)))

The read/write functions use the copy from the stack frame and it is cleaned up when that frame is removed.

When you pass these around from the read/write functions, you're not passing pointers or addresses, so it looks like you're copying out to other functions, too.

@tmsimont
Copy link
Owner

Also I don't think Address() is even necessary if we move index/offset/tag parse responsibility to the cache ( #1 )

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants