(b) Suppose your program will (ideally) run for weeks at a time to record sensor mea- surements. The following function is called every minute. It allocates space for and returns the pointer to a 6-byte struct, like follows: MyStruct* runs_every_minute() MyStruct* pX = new Mystruct; // note: sizeof(MyStruct) is 6 // .. return pX; Sadly, the program never calls delete on the resulting pointer, so the 6-bytes are leaked each time the function is called. How many days of continuous operation would it take before you expect your pro- gram to fail with an "out of memory" error? (Assume that the stack is negligible, that is, use the part (a) answer as the size of the free store.) Show your calculation.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
C++ please answer b part
9. Imagine you are developing a program for the ESP32 microcontroller, which has 320kb
of RAM. This memory must be shared between the stack and the free store... and we
have to save room for the executable itself! If you want to use WiFi or Bluetooth then
you have to #include libraries which add considerable heft to your compiled executable.
Lets imagine the executable consumes 243kb of RAM.
(a) How much space is left for the stack and the free store to share?
(b) Suppose your program will (ideally) run for weeks at a time to record sensor mea-
surements. The following function is called every minute. It allocates space for and
returns the pointer to a 6-byte struct, like follows:
MyStruct* runs_every_minute()
MyStruct* pX
// note: sizeof(MyStruct) is 6
= new Mystruct;
//
return pX;
Sadly, the program never calls delete on the resulting pointer, so the 6-bytes are
leaked each time the function is called.
How many days of continuous operation would it take before you expect your pro-
gram to fail with an "out of memory" error? (Assume that the stack is negligible,
that is, use the part (a) answer as the size of the free store.)
Show your calculation.
Transcribed Image Text:9. Imagine you are developing a program for the ESP32 microcontroller, which has 320kb of RAM. This memory must be shared between the stack and the free store... and we have to save room for the executable itself! If you want to use WiFi or Bluetooth then you have to #include libraries which add considerable heft to your compiled executable. Lets imagine the executable consumes 243kb of RAM. (a) How much space is left for the stack and the free store to share? (b) Suppose your program will (ideally) run for weeks at a time to record sensor mea- surements. The following function is called every minute. It allocates space for and returns the pointer to a 6-byte struct, like follows: MyStruct* runs_every_minute() MyStruct* pX // note: sizeof(MyStruct) is 6 = new Mystruct; // return pX; Sadly, the program never calls delete on the resulting pointer, so the 6-bytes are leaked each time the function is called. How many days of continuous operation would it take before you expect your pro- gram to fail with an "out of memory" error? (Assume that the stack is negligible, that is, use the part (a) answer as the size of the free store.) Show your calculation.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education