-
Notifications
You must be signed in to change notification settings - Fork 68
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
Message memory management using smart pointers #6
Comments
…syntax. Also, changes situations where comp().comp() occured to iso_vector_.comp(). The former (comp().comp()) threw errors in Material::clone() function testing (added here). The latter does not throw such errors. For reference, a backtrace of the sort of errors the former threw follows (the 'identifier' in question is always different, btw): [----------] 2 tests from MaterialTest [ RUN ] MaterialTest.Constructors [ OK ] MaterialTest.Constructors (0 ms) [ RUN ] MaterialTest.Clone terminate called after throwing an instance of 'CycRangeException' what(): cyclus exception: Isotope identifier '574365655' is not valid. Program received signal SIGABRT, Aborted. 0x00007fff85dbc0b6 in __kill () (gdb) bt #0 0x00007fff85dbc0b6 in __kill () #1 0x00007fff85e5c9f6 in abort () #2 0x00007fff87d7e5d2 in __gnu_cxx::__verbose_terminate_handler () #3 0x00007fff87d7cae1 in __cxxabiv1::__terminate () #4 0x00007fff87d7cb16 in std::terminate () #5 0x00007fff87d7cbfc in __cxa_throw () #6 0x0000000100084be1 in IsoVector::validateIsotopeNumber () #7 0x0000000100084d2d in IsoVector::atomCount () #8 0x000000010008949b in Material::checkQuality () #9 0x00000001000e6616 in MaterialTest_Clone_Test::TestBody () #10 0x000000010159b7dd in testing::Test::Run () #11 0x00000001015a246e in testing::internal::TestInfoImpl::Run () #12 0x00000001015a25a4 in testing::TestCase::Run () #13 0x00000001015a2872 in testing::internal::UnitTestImpl::RunAllTests () #14 0x00000001015a29e9 in testing::UnitTest::Run () #15 0x0000000100020130 in main () (gdb)
actually, shared_ptr doesn't work for the Message class because of the way messages send themselves by passing their this pointers as an argument from inside the sendOn and approveTransfer methods. Using shared pointers would result in multiple shared pointer objects tracking the same Message object in memory (very bad). I will be using intrusive pointers to overcome this problem - each message object will track its own reference count. |
fixed gtest file that got corrupted from sed replace. added forgotten boost namespace specifier. see issue #6.
added MemAlloc prefix to log messages dealing with memory allocation. see issue #6.
Use Boost shared_ptr and weak_ptr (to prevent parent/child cycles) for cyclus memory management. Eventually, the entire core needs to be converted from raw pointers to smart pointers. Note that the == operator still works for pointer comparisons between smart pointers.
The text was updated successfully, but these errors were encountered: