@ne
ne said:
¿why is snapshot_class::snapshot a pointer? |
It isn't, look at the code.
ne said:
the temporary dies after that line, ¿how are you measuring the memory usage? |
I know, but for some reason, it carries on, and I don't knwo why. I run task manager and monitor the memory usage through it, and it has over 40,000 Kb allocated until it's scope ends, or it is manually deallocated. After that, there is between 1,000 and 5,000 Kb left in leaked memory.
ne said:
well, snap.path.snapshot should still point to that memory, so it wouldn't be released |
I don't think you quite read my code. In the class, the map is declared as a
shared_ptr
and when
snapshot_class::clear()
is called, that pointer is reset, clearing the memory.
snap is not a class, it is a data structure.
snapshot_class snapshot = snap.path;
declares a class with the handle
snapshot
with
snap.path
as the argument for construction.
**********************************************************************
I'll explain a little more how the class is supposed to work:
the
snapshot_class
can be constructed with the following arguments:
1 2 3
|
const string&
const char*
[nothing]
|
when given a string it will assume that string is a file path and attempt to load it as a 'snapshot'. This fills
snapshot_class::snapshot
with a list of string that represent paths which make up a 'snapshot'. In my case, there are over 207,000 paths loaded, and this is not in administrative mode (so it would pick up more if run in admin mode).
when given no argument, it creates a snapshot. This recursively iterates through every file/folder, and directly writes them to a file.
When comparing 2 snapshots, the list will need to be retrieved from the class, but not modified. I also don't want it to be able to be modified.
When the data is retrieved, as in my example with the menu, it creates a memory leak.