Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7039277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:46:41+00:00 2026-05-28T01:46:41+00:00

I have a basic question regarding memory management in TCL. Suppose I have a

  • 0

I have a basic question regarding memory management in TCL.

  1. Suppose I have a Tcl procedure. Inside the procedure I declare an array and add some data in it. I do some number crunching on that array. My question is before the procedure returns do I need to manually delete the array? Using:

    unset <array_name>
    

    My answer is no. But I am not sure since I don’t know if there is a garbage collector in Tcl. Can anyone comment on this please.

  2. Is using array in Tcl bad? I want to create Array of lists and while reading discussions on stack overflow people told to use dict for these kind of stuff but since I have Tcl 8.4 I can’t. What is the problem with arrays in Tcl?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:46:41+00:00Added an answer on May 28, 2026 at 1:46 am
    1. Suppose I have a Tcl procedure. Inside the procedure I declare an array and add some data in it. I do some number crunching on that array. My question is before the procedure returns do I need to manually delete the array?

    No. It will be deleted when the procedure returns (i.e., its lifespan is bounded to that of the stack frame). You may unset it earlier if you wish, which will free up its memory then, but you don’t need to do that.

    1. Is using array in Tcl bad? I want to create Array of lists and while reading discussions on stack overflow people told to use dict for these kind of stuff but since I have Tcl 8.4 I can’t. What is the problem with arrays in Tcl?

    Arrays are absolutely fine in 8.4, so long as you remember that they are a collection that implements a map from arbitrary string keys to variables. Dicts are for cases where you want a value that holds a map from strings to arbitrary values. (There’s a dict extension for 8.4 somewhere about.) You can use arrays to model matrices by choosing some character as a separator between the sub-indices (e.g., a comma) and this technique has been used by many people to great effect.

    However it is more efficient to model them as lists of lists; the lset and multi-index lindex permit efficient update and lookup of elements of the resulting matrix. (It is a bit verbose though.) If you’re dealing with a lot of data, the improved efficiency can be very useful. (Sparse matrices may be better done as a Tcl array despite that.) Also note that if you can upgrade to 8.5, a number of operations there are significantly faster (notably including testing for the presence of an element of an array with info exists).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to QuickFIX and I have some basic question regarding QuickFix: 1)
I just started using QT and I have a question regarding some basic stuff.
I have a basic question regarding populating Core Data with data. I am building
I have a basic question regarding timers. My timer is acting very strange. I
Sorry for such a basic question regarding lists, but do we have this feature
I have a question regarding the Phonegap basic architecture design: 1.The phonegap project contains
I have a basic question regarding the const pointers. I am not allowed to
I have a basic question regarding assignment of a list of subclass to a
I have very basic question regarding return value of a function, and checking the
I have a very basic question regarding properties in Objective-C. I can only access

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.