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 7072151
In Process

The Archive Base Latest Questions

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

Hi all when writing an array list implementation, I understand it is important to

  • 0

Hi all when writing an array list implementation, I understand it is important to set Item(x) to null when it is removed (instead of simply quantity -= 1) so as to prevent memory leaks.

However, if my array list is a primitive int array list (backed by a int[]), does it make sense to set it to 0?

Similary, for an array list of primitive chars (backed by a char[]), when RemoveRange() is called, does it make sense to fill that range with \u0000? Or is it totally fine simply to update the length and pointers without modifying the backing array?

Is an array of ints filled with zeros possibly less memory-occupying than an equal length array filled with integer values because the runtime could make optimizations ?

  • 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-28T05:46:26+00:00Added an answer on May 28, 2026 at 5:46 am

    Is an array of ints filled with zeros possibly less memory-occupying than an equal length array filled with integer values?

    Assuming in both cases we’re dealing with an int[] – no. Two arrays of the same type and the same length will always occupy the same amount of memory.

    There’s no need to overwrite your “now empty” array elements with 0. It wouldn’t do any harm (beyond a tiny performance benefit), and may even make things simpler when debugging, but you don’t need to.

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

Sidebar

Related Questions

I'm writing a library and instead of returning a byte array from an EventArgs
I am working on a solo project, writing all code myself so no collaboration
In the following program, loop is iterating 1000 times, and I am writing all
I'm going to write a CMS, but right now I'm writing down all my
I am writing an application where all the request to the internet should go
I am writing a catch all method for my controller for ajax. It is
I'm writing a query to get ALL of the products in the products table,
I'm writing a database of all DVDs I have at home. One of the
I hear people writing these programs all the time and I know what they
Should I be writing Doc Comments for all of my java methods?

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.