This shows you the differences between two versions of the page.
ep:labs:02:contents:tasks:ex2 [2019/10/06 14:35] radu.mantu |
ep:labs:02:contents:tasks:ex2 [2025/02/11 23:22] (current) cezar.craciunoiu [02. [10p] Feedback] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | == 02. [20p] Memory usage == | + | ==== [10p] Feedback ==== |
- | Open {{:ep:labs:ep2017_l2_ex02.txt|ex03.py}} and take a look at the code. What is the difference between the methods //do_append()// and //do_allocate()//? | + | Please take a minute to fill in the **[[https://forms.gle/NpSRnoEh9NLYowFr5 | feedback form]]** for this lab. |
- | + | ||
- | Use //vmstat// to monitor the memory usage while performing the following experiments. In the main method, call: | + | |
- | * The //do_append// method on it's own (see //Experiment 1//). | + | |
- | * The //do_allocate// method on it's own (see //Experiment 2//). | + | |
- | * Both methods as shown in the //Experiment 3// area in the code. | + | |
- | * Both methods as shown in the //Experiment 4// area in the code. | + | |
- | Offer an interpretation for the obtained results. | + | |
- | + | ||
- | <solution -hidden> | + | |
- | * **Experiment 1,2:** There is not much difference in terms of memory usage between Experiment 1 and 2. | + | |
- | * **Experiment 3:** The //do_append// method starts using memory. After it finished running, since there is no reference for the generated array, the allocated memory is unallocated (reference counting garbage collector). Then the next method, //do_allocate//, starts running and using memory. | + | |
- | * **Experiment 4:** After the first method ends, since in this case there is a reference for the generated array, the memory is not unallocated. When the second method starts running, the amount of memory that it uses is added to the amount already used by the first method. If the used memory is taking up almost all the available free memory of the system, you can notice: swpd increasing, buff decreasing, cache decreasing, and si, so, bi, bo activity. | + | |
- | + | ||
- | Notice the increased number of interrupts and context switches. These are caused by time.sleep(). | + | |
- | + | ||
- | TODO - sa le dam acelasi cod in C (nu are garbage collector) si in JAVA (garbage collectorul e diferit - mark and sweep). | + | |
- | </solution> | + |