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

  • Home
  • SEARCH
  • 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 739525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:24:39+00:00 2026-05-14T08:24:39+00:00

the following method will be called many times. i’m concerned the continuous call for

  • 0

the following method will be called many times. i’m concerned the continuous call for new rectangles will add potentially unnecessary memory consumption, or is the memory used to produce the previous rectangle released/overwritten to accommodate another rectangle since it is assigned to the same instance variable?

private function onDrag(evt:MouseEvent):void
        {
        this.startDrag(false, dragBounds());
        }

private function dragBounds():Rectangle
    {
    var stagebounds = new Rectangle(0 - swatchRect.x, 0 - swatchRect.y, stage.stageWidth - swatchRect.width, stage.stageHeight - swatchRect.height);
    return stagebounds;
    }
  • 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-14T08:24:39+00:00Added an answer on May 14, 2026 at 8:24 am

    It is a quick question, but very important! Too few ActionScript developers care enough the even consider these things. So kudos to you!

    Everytime you create a new rectangle, new memory is being allocated for it. As soon as all references to that rectangle are removed it becomes eligible for garbage collection (GC), meaning the next time the GC runs it’ll be freed from memory. (In this case all references are removed when you call stopDrag())

    An instance of Rectangle takes very little memory up, and with the garbage collector running at regular intervals, instances will constantly be cleaned up. Additionally, we can be certain that no more than one will be created at any given time without a previous instance being made available for GC. (Assuming you’ll be calling stopDrag before you call dragBounds again.)

    Really, this is a case where you just don’t need to worry about it. Your code is fine as is. You would need many thousands of Rectangles (like millions, at one time) before you run into any potential issues.

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

Sidebar

Related Questions

I'm wondering if the following method will completely prevent CSRF, and be compatible with
Why something like following is not allowed. I mean why the following method will
I have a method that I will use in the following contexts: 1. User
The following method, when called with something like String val = getCell(SELECT col FROM
Do I need to protect my interrupt handler being called many times for the
The following small example implements a singleton pattern that I've seen many times: #include
I’m after some C# code that will have the following methods that will return
The following method calculates cost. It access other classes when required. Cloud class holds
The following method is launched from the constructor of UserControl. A cross thread exception
The following method does not apply the wpf changes (background = red) until the

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.