Skip to content

Commit

Permalink
Fixing memory being used too much
Browse files Browse the repository at this point in the history
  • Loading branch information
msoos committed Jul 8, 2024
1 parent b735c94 commit ffcf4e0
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion scripts/build_scripts
6 changes: 4 additions & 2 deletions src/clauseallocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ ClOffset ClauseAllocator::move_cl(
ClOffset* newDataStart
, ClOffset*& new_ptr
, Clause* old
) const {
) {
uint64_t bytesNeeded = sizeof(Clause) + old->size()*sizeof(Lit);
uint64_t sizeNeeded = bytesNeeded/sizeof(BASE_DATA_TYPE) + (bool)(bytesNeeded % sizeof(BASE_DATA_TYPE));
memcpy(new_ptr, old, sizeNeeded*sizeof(BASE_DATA_TYPE));
Expand All @@ -209,6 +209,7 @@ ClOffset ClauseAllocator::move_cl(
(*old)[1] = Lit::toLit((new_offset>>32) & 0xFFFFFFFF);
#endif
old->reloced = true;
new_sz_while_moving += sizeNeeded;

new_ptr += sizeNeeded;
return new_offset;
Expand Down Expand Up @@ -265,6 +266,7 @@ void ClauseAllocator::consolidate(
return;
}
const double my_time = cpuTime();
new_sz_while_moving = 0;

//Pointers that will be moved along
BASE_DATA_TYPE * const newDataStart = (BASE_DATA_TYPE*)malloc(currentlyUsedSize*sizeof(BASE_DATA_TYPE));
Expand Down Expand Up @@ -308,7 +310,7 @@ void ClauseAllocator::consolidate(
const uint64_t old_size = size;
size = new_ptr-newDataStart;
capacity = currentlyUsedSize;
currentlyUsedSize = size;
currentlyUsedSize = new_sz_while_moving;
free(dataStart);
dataStart = newDataStart;

Expand Down
3 changes: 2 additions & 1 deletion src/clauseallocator.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ class ClauseAllocator {
ClOffset* newDataStart
, ClOffset*& new_ptr
, Clause* old
) const;
);

uint32_t new_sz_while_moving;
BASE_DATA_TYPE* dataStart; ///<Stack starts at these positions
uint64_t size; ///<The number of BASE_DATA_TYPE datapieces currently used in each stack
/**
Expand Down
2 changes: 1 addition & 1 deletion utils/minisat
Submodule minisat updated 1 files
+1 −1 CMakeLists.txt

0 comments on commit ffcf4e0

Please sign in to comment.