Memory efficiency: One large dictionary or a dictionary of smaller dictionaries?

Three suggestions: Use one dictionary. It’s easier, it’s more straightforward, and someone else has already optimized this problem for you. Until you’ve actually measured your code and traced a performance problem to this part of it, you have no reason not to do the simple, straightforward thing. Optimize later. If you are really worried about …

Read more

C++11 atomic memory ordering – is this a correct usage of relaxed (release-consume) ordering?

Why are you loading the old flags value twice in your CAS loops? The first time is by flags.load(), and the second by the compare_exchange_weak(), which the standard specifies on CAS failure will load the previous value into the first argument, which in this case is flagsNow. According to http://en.cppreference.com/w/cpp/atomic/atomic/compare_exchange, “Otherwise, loads the actual value …

Read more

How to improve memory sharing between unicorn processes with Ruby 2.0 on Linux

According to this answer, which you may have already seen, there is a line that reads: Note that a “share-able” page is counted as a private mapping until it is actually shared. i.e. if there is only one process currently using libfoo, that library’s text section will appear in the process’s private mappings. It will …

Read more

save data from visual studio memory window

user142207 has done a great job investigating VS internals, I recommend that solution. I have another way that was invented by my colleague, Sergey S., which is very useful: Windows: Use a couple of functions ReadProcessMemory/WriteProcessMemory. It needs a standalone app that calls these functions with a target process id like: dumper.exe <debugged process id> …

Read more

Vector storage in C++

If you define your Point as having contiguous data storage (e.g. struct Point { int a; int b; int c; } or using std::array), then std::vector<Point> will store the Points in contiguous memory locations, so your memory layout will be: p0.a, p0.b, p0.c, p1.a, p1.b, p1.c, …, p(N-1).a, p(N-1).b, p(N-1).c On the other hand, if …

Read more