Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The consumption of memory by the deque container is unusually high. #26

Open
Junming-Liang opened this issue Aug 17, 2023 · 0 comments
Open

Comments

@Junming-Liang
Copy link

I have utilized CTL on the STM32E407 equipped with FreeRTOS; nevertheless, each instance whereby the deque is employed results in program paralysis. Through experimentation, I discerned an anomalous memory consumption when the deque is in use. This discrepancy causes no issues when operating on a desktop computer; however, it leads to freezing when platforms such as microcontrollers are employed.
It's feasible to draw a comparison between the memory consumption of the deque container and that of the vector container.

  printf("before init vec the min free stack size is %d \r\n",(int32_t)uxTaskGetStackHighWaterMark(NULL));
  printf("before init vec the min free heap size is %d \r\n",(int32_t)xPortGetFreeHeapSize());
  vec_double temp =vec_double_init();
  printf("after init vec the the min free stack size is %d \r\n",(int32_t)uxTaskGetStackHighWaterMark(NULL));
  printf("after init vec the the min free heap size is %d \r\n",(int32_t)xPortGetFreeHeapSize());
  vec_double_resize(&temp,3,0.0);
  printf("after push back to vec the min free stack size is %d \r\n",(int32_t)uxTaskGetStackHighWaterMark(NULL));
  printf("after push back to vec the min free heap size is %d \r\n",(int32_t)xPortGetFreeHeapSize());  
  printf("before init deq the min free stack size is %d \r\n",(int32_t)uxTaskGetStackHighWaterMark(NULL));
  printf("before init deq the min free heap size is %d \r\n",(int32_t)xPortGetFreeHeapSize());
  deq_double temp2 =deq_double_init();
  printf("after init deq the the min free stack size is %d \r\n",(int32_t)uxTaskGetStackHighWaterMark(NULL));
  printf("after init deq the the min free heap size is %d \r\n",(int32_t)xPortGetFreeHeapSize());
  deq_double_resize(&temp2,3,0.0);
  printf("after push back to deq the min free stack size is %d \r\n",(int32_t)uxTaskGetStackHighWaterMark(NULL));
  printf("after push back to deq the min free heap size is %d \r\n",(int32_t)xPortGetFreeHeapSize());  

Output is:

[12:05:59:396] before init vec the min free stack size is 8866 ␍␊
[12:05:59:399] before init vec the min free heap size is 15880 ␍␊
[12:05:59:409] after init vec the the min free stack size is 8776 ␍␊
[12:05:59:413] after init vec the the min free heap size is 15880 ␍␊
[12:05:59:423] after push back to vec the min free stack size is 8776 ␍␊
[12:05:59:426] after push back to vec the min free heap size is 15848 ␍␊
[12:05:59:437] before init deq the min free stack size is 8758 ␍␊
[12:05:59:440] before init deq the min free heap size is 15848 ␍␊
[12:05:59:450] after init deq the the min free stack size is 8758 ␍␊
[12:05:59:453] after init deq the the min free heap size is 15848 ␍␊
[12:05:59:464] after push back to deq the min free stack size is 8758 ␍␊
[12:05:59:467] after push back to deq the min free heap size is 11720 ␍

Within the deque, storing a mere three double variables surprisingly consumed almost 4000 bytes of memory, a figure I perceive as incorrect. I have initiated the utilization of a vector container as a substitute for the deque, however, does a superior solution exists to remedy this issue? I avidly anticipate your response.

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

No branches or pull requests

1 participant