# Newbie question - variables and memory

**URL:** <https://www.ruby-forum.com/t/newbie-question-variables-and-memory/99462>\
**Category:** Ruby\
**Created:** [July 22, 2006, 11:26pm UTC](https://www.ruby-forum.com/t/newbie-question-variables-and-memory/99462 "2006-07-22T23:26:53Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ben-v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@ben-v](https://www.ruby-forum.com/u/ben-v)\
**Post date:** [July 22, 2006, 11:26pm UTC](https://www.ruby-forum.com/t/newbie-question-variables-and-memory/99462/1 "2006-07-22T23:26:53Z")

</div>

I may be wrong, but I might have read somewhere that there’s a need to  
delete variables from memory. In my web environment, can the same  
variable or instance (@) variable retain the same value across multiple  
requests, or was that about something else? (I know about session and  
fom variables, and flashes, but I’m talking about regular variables or  
instance variables) Thanks for your help and time.

---

<div class="post-metadata">

**Author:** ![ben-v](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ecb155/32.png) [@ben-v](https://www.ruby-forum.com/u/ben-v)\
**Post date:** [July 23, 2006, 4:02am UTC](https://www.ruby-forum.com/t/newbie-question-variables-and-memory/99462/2 "2006-07-23T04:02:15Z")

</div>

Ben V. wrote:

> I may be wrong, but I might have read somewhere that there’s a need to  
> delete variables from memory.

In normal usage, no. Ruby supports garbage collection, meaning that  
memory allocated for objects no longer reachable will be reclaimed.

> In my web environment, can the same  
> variable or instance (@) variable retain the same value across multiple  
> requests, or was that about something else? (I know about session and  
> fom variables, and flashes, but I’m talking about regular variables or  
> instance variables)

You are talking about two very different things. Here, I think you’re  
digressing into CGI. And in that case, you should see the Sessions  
section of this article: [http://www.rubycentral.com/articles/cgi.html](http://www.rubycentral.com/articles/cgi.html)

Management of CGI session data is wholly distinct from Ruby’s  
management of objects in general. Ruby the language knows nothing about  
CGI, CGI sessions, or persistent data from those sessions. These are  
implemented via the external CGI library.
