Skip to content

Fixing memory leaks#31

Closed
FJShen wants to merge 5 commits intoaccel-sim:devfrom
FJShen:dev
Closed

Fixing memory leaks#31
FJShen wants to merge 5 commits intoaccel-sim:devfrom
FJShen:dev

Conversation

@FJShen
Copy link
Copy Markdown

@FJShen FJShen commented Mar 11, 2022

Fixed several memory leaks or incorrect memory allocations . Bugs were identified by running valgrind on AccelSim in PTX mode.

@FJShen FJShen changed the title Fixed a couple of memory leaks/errors Fixed a couple of simple memory leaks/errors Mar 11, 2022
…ng a bare pointer. This was one of the causes for memory leak in PTX mode
@FJShen FJShen changed the title Fixed a couple of simple memory leaks/errors Fixing memory leaks Mar 21, 2022
unsigned num_inst = m_instructions.size();
m_instr_mem_size = MAX_INST_SIZE * (num_inst + 1);
m_instr_mem = new ptx_instruction *[m_instr_mem_size];
m_instr_mem = std::unique_ptr<ptx_instruction*[]>(new ptx_instruction* [m_instr_mem_size]);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The entire array allocated by new[] will be destroyed and deleted once m_instr_mem - the unique_ptr - goes out of scope.

@FJShen FJShen marked this pull request as draft March 26, 2022 21:13
@FJShen FJShen mentioned this pull request Mar 26, 2022
@FJShen
Copy link
Copy Markdown
Author

FJShen commented Mar 26, 2022

continued at PR #34

@FJShen FJShen closed this Mar 26, 2022
@FJShen FJShen deleted the dev branch March 26, 2022 22:18
@FJShen FJShen restored the dev branch March 26, 2022 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant