Skip to content

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

Description

@Junming-Liang

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions