# Data Lifetime

ezel retains user data in memory until the object is dropped.

```rust
for _ in 0..1000 {
    plot.scatter(random_million_points());
}
// plot has 1_000*1_000_000 points in memory

// layout and axis limits are determined from 1_000*1_000_000 points
plot.draw_to_file("large.png", (500, 500)).unwrap();
```

Sometimes it is desirable to save the memory by dumping the data onto the bitmap target and dropping the data immediately. ezel does not support this yet, meanwhile you can use [plotters](https://github.com/38/plotters) library at the cost of manual specification of layouts and limits.

```rust
// Plotters example
use plotters::prelude::*;

let mut cc = ChartBuilder::on(&upper)
    .margin(5)
    .set_all_label_area_size(50)  // you should manually calculate this
    .caption("Sine and Cosine", ("sans-serif", 40))
    .build_cartesian_2d(-3.4f32..3.4, -1.2f32..1.2f32)?;

cc.configure_mesh()
    .x_labels(20)  // you should manually calculate this
    .y_labels(10)  // you should manually calculate this
    .disable_mesh()
    .x_label_formatter(&|v| format!("{:.1}", v))
    .y_label_formatter(&|v| format!("{:.1}", v))
    .draw()?;
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ezel.rustic.dev/optimization/data-lifetime.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
