Describe the bug
When the user doesn't check if the queue is full in their program, memory leaks indefinitely as IO commands created in kv_store (and other commands) are not freed when the queue is full, and new commands are created on the retry.
To Reproduce
Steps to reproduce the behavior:
Confirm free system memory with free
Run the following modified version of the insertion routine in test_async.cpp
Alternatively, it can also be fixed by changing kernel_driver_adapter/src/kv_device.cpp: kv_store: submit_io, from
if (kque->full()) {
return KV_ERR_QUEUE_IS_FULL;
} else {
// send to real device directly for execution
// actually only in a queue inside device driver for asyncIO
// Please note this is not actual execution, it's just sent to device
// for asynchronous execution.
// Ideally device should export a queue interface for sending commands
kv_result res = cmd->execute_cmd();
if (res == KV_SUCCESS) {
kque->increase_qdepth();
}
return res;
}
to
if (kque->full()) {
free(cmd);
return KV_ERR_QUEUE_IS_FULL;
} else {
// send to real device directly for execution
// actually only in a queue inside device driver for asyncIO
// Please note this is not actual execution, it's just sent to device
// for asynchronous execution.
// Ideally device should export a queue interface for sending commands
kv_result res = cmd->execute_cmd();
if (res == KV_SUCCESS) {
kque->increase_qdepth();
}
return res;
}
The same pattern is also repeated in many places throughout the code.
Location (Korea, USA, China, India, etc.) Korea
Describe the bug When the user doesn't check if the queue is full in their program, memory leaks indefinitely as IO commands created in kv_store (and other commands) are not freed when the queue is full, and new commands are created on the retry.
To Reproduce Steps to reproduce the behavior:
Expected behavior Reasonable memory usage
System environment (please complete the following information)
Workload
Additional context
The problem can be fixed by modifying kernel_driver_adapter/src/kv_device.cpp: kv_store, from
to
Alternatively, it can also be fixed by changing kernel_driver_adapter/src/kv_device.cpp: kv_store: submit_io, from
to
The same pattern is also repeated in many places throughout the code.