Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
emper
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schmaus
emper
Commits
d33cd06f
Commit
d33cd06f
authored
3 years ago
by
Florian Schmaus
Browse files
Options
Downloads
Patches
Plain Diff
[MemoryManager] Free the memory in the queues and the queues on destruction
parent
99092a76
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Pipeline
#77634
passed
3 years ago
Stage: smoke-test
Stage: test
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
emper/MemoryManager.hpp
+26
-1
26 additions, 1 deletion
emper/MemoryManager.hpp
with
26 additions
and
1 deletion
emper/MemoryManager.hpp
+
26
−
1
View file @
d33cd06f
...
...
@@ -14,6 +14,8 @@ class MemoryManager {
private:
const
workerid_t
workerCount
;
adt
::
BoundedBumpArray
<
void
,
WORKER_EXCLUSIVE_QUEUE_SIZE
>**
workerExclusiveQueues
;
adt
::
WsClQueue
<
void
*
,
WS_QUEUE_SIZE
>**
queues
;
static
thread_local
adt
::
BoundedBumpArray
<
void
,
WORKER_EXCLUSIVE_QUEUE_SIZE
>
workerExclusiveQueue
;
...
...
@@ -32,6 +34,8 @@ class MemoryManager {
public
:
MemoryManager
(
Runtime
&
runtime
);
~
MemoryManager
();
auto
getMemory
(
bool
*
malloced
)
->
void
*
{
*
malloced
=
false
;
void
*
memory
=
workerExclusiveQueue
.
get
();
...
...
@@ -88,7 +92,28 @@ template <typename T, intptr_t WS_QUEUE_SIZE, size_t WORKER_EXCLUSIVE_QUEUE_SIZE
MemoryManager
<
T
,
WS_QUEUE_SIZE
,
WORKER_EXCLUSIVE_QUEUE_SIZE
>::
MemoryManager
(
Runtime
&
runtime
)
:
workerCount
(
runtime
.
getWorkerCount
())
{
queues
=
new
adt
::
WsClQueue
<
void
*
,
WS_QUEUE_SIZE
>*
[
workerCount
];
workerExclusiveQueues
=
new
adt
::
BoundedBumpArray
<
void
,
WORKER_EXCLUSIVE_QUEUE_SIZE
>*
[
workerCount
];
auto
newWorkerHook
=
[
this
](
workerid_t
workerId
)
{
queues
[
workerId
]
=
&
queue
;
};
auto
newWorkerHook
=
[
this
](
workerid_t
workerId
)
{
workerExclusiveQueues
[
workerId
]
=
&
workerExclusiveQueue
;
queues
[
workerId
]
=
&
queue
;
};
runtime
.
addNewWorkerHook
(
newWorkerHook
);
}
template
<
typename
T
,
intptr_t
WS_QUEUE_SIZE
,
size_t
WORKER_EXCLUSIVE_QUEUE_SIZE
>
MemoryManager
<
T
,
WS_QUEUE_SIZE
,
WORKER_EXCLUSIVE_QUEUE_SIZE
>::~
MemoryManager
()
{
for
(
workerid_t
i
=
0
;
i
<
workerCount
;
++
i
)
{
auto
*
queue
=
workerExclusiveQueues
[
i
];
while
(
auto
*
mem
=
queue
->
get
())
free
(
mem
);
}
delete
workerExclusiveQueues
;
for
(
workerid_t
i
=
0
;
i
<
workerCount
;
++
i
)
{
auto
*
queue
=
queues
[
i
];
void
*
mem
;
while
(
queue
->
popBottom
(
&
mem
))
free
(
mem
);
}
delete
queues
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment