Fixed lost chunks in free_overlap

This commit is contained in:
Victor Olin 2023-03-20 13:59:19 +01:00
parent ffdffc475d
commit 4bf1fd7610
2 changed files with 21 additions and 13 deletions

View file

@ -380,11 +380,14 @@ namespace GC
std::vector<Chunk *> filtered;
size_t i = 0;
// filtered.push_back(heap->m_freed_chunks.at(i++));
filtered.push_back(Heap::get_at(heap->m_freed_chunks, i++));
// filtered.push_back(Heap::get_at(heap->m_freed_chunks, i++));
auto prev = Heap::get_at(heap->m_freed_chunks, i++);
prev->marked = true;
filtered.push_back(prev);
cout << filtered.back()->start << endl;
for (; i < heap->m_freed_chunks.size(); i++)
{
auto prev = filtered.back();
prev = filtered.back();
// auto next = heap->m_freed_chunks.at(i);
auto next = Heap::get_at(heap->m_freed_chunks, i);
auto p_start = (uintptr_t)(prev->start);
@ -392,10 +395,25 @@ namespace GC
auto n_start = (uintptr_t)(next->start);
if (n_start >= (p_start + p_size))
{
next->marked = true;
filtered.push_back(next);
}
}
heap->m_freed_chunks.swap(filtered);
bool profiler_enabled = heap->profiler_enabled();
// after swap m_freed_chunks contains still available chunks
// and filtered contains all the chunks, so delete unused chunks
for (Chunk *chunk : filtered)
{
// if chunk was filtered away, delete it
if (!chunk->marked)
{
if (profiler_enabled)
Profiler::record(ChunkFreed, chunk);
delete chunk;
}
}
}
// ----- ONLY DEBUGGING -----------------------------------------------------------------------

View file

@ -6,9 +6,6 @@ Goal for next week (24/2):
- Write more complex tests
## GC TODO:
- Skriva klart profiler
- fixa abs_path i create_file_stream
- delete chunk i free_overlap
- Kolla linking med Valter/Victor
- Fixa en a-fil/static lib till Samuel
- Kolla vektor vs list complexity
@ -16,11 +13,4 @@ Goal for next week (24/2):
då är alla efter varandra i minnet.
## Tests TODO
- Write complex datastructures for tests with larger programs
## Profiler grejer
1. [x] Kolla existerande events
2. [x] Nya events för init, dispose i heap.cpp
3. [x] Skriv om try_recycle för att returnera en chunk
4. [x] Copy constructor för chunks (reused chunks)
5. [x] Nya events för try_recycle
- Write complex datastructures for tests with larger programs