Questions tagged [memory]

Use this tag for memory management or issues in programming. For questions about memory hardware issues or errors in general software, go to https://superuser.com, or https://serverfault.com if this is related to enterprise-level hardware or software.

In computing, memory refers to the physical devices used to store programs (sequences of instructions) or data (e.g. program state information) on a temporary or permanent basis for use in a computer or other digital electronic device.

The term primary memory is used for the information in physical systems which function at high-speed (i.e. RAM), as a distinction from secondary memory, which are physical devices for program and data storage which are slow to access but offer higher memory capacity. Check the tag for more details.

Primary memory stored on secondary memory is called "virtual memory", which can be seen under the tag .

An important facet of programming is the interaction with a computer's memory. For specific issues with memory management, check the tag.

External Link: What every programmer should know about memory

32853 questions
3428
votes
59 answers

How can I create a memory leak in Java?

I just had an interview, and I was asked to create a memory leak with Java. Needless to say, I felt pretty dumb having no clue on how to even start creating one. What would an example be?
MatBanik
  • 24,206
  • 38
  • 107
  • 172
1152
votes
22 answers

How do I determine the size of my array in C?

How do I determine the size of my array in C? That is, the number of elements the array can hold?
Mark Harrison
  • 267,774
  • 112
  • 308
  • 434
813
votes
9 answers

How do I discover memory usage of my application in Android?

How can I find the memory used on my Android application, programmatically? I hope there is a way to do it. Plus, how do I get the free memory of the phone too?
Andrea Baccega
  • 25,523
  • 12
  • 41
  • 44
806
votes
13 answers

How do I determine the size of an object in Python?

I want to know how to get size of objects like a string, integer, etc. in Python. Related question: How many bytes per element are there in a Python list (tuple)? I am using an XML file which contains size fields that specify the size of value. I…
user46646
  • 133,483
  • 43
  • 73
  • 82
796
votes
9 answers

What is a "cache-friendly" code?

What is the difference between "cache unfriendly code" and the "cache friendly" code? How can I make sure I write cache-efficient code?
Noah Roth
  • 8,210
  • 5
  • 17
  • 24
778
votes
32 answers

How can I measure the actual memory usage of an application or process?

This question is covered here in great detail. How do you measure the memory usage of an application or process in Linux? From the blog article of Understanding memory usage on Linux, ps is not an accurate tool to use for this intent. Why ps is…
ksuralta
  • 14,098
  • 16
  • 34
  • 36
663
votes
31 answers

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted (CodeIgniter + XML-RPC)

I have a bunch of client point of sale (POS) systems that periodically send new sales data to one centralized database, which stores the data into one big database for report generation. The client POS is based on PHPPOS, and I have implemented a…
ArcticZero
  • 6,671
  • 3
  • 17
  • 8
647
votes
10 answers

How to determine CPU and memory consumption from inside a process?

I once had the task of determining the following performance parameters from inside a running application: Total virtual memory available Virtual memory currently used Virtual memory currently used by my process Total RAM available RAM currently…
Lanzelot
  • 13,862
  • 4
  • 16
  • 13
638
votes
26 answers

In Java, what is the best way to determine the size of an object?

I have an application that reads a CSV file with piles of data rows. I give the user a summary of the number of rows based on types of data, but I want to make sure that I don't read in too many rows of data and cause OutOfMemoryErrors. Each row…
Jay R.
  • 29,837
  • 17
  • 50
  • 61
520
votes
23 answers

Which is faster: Stack allocation or Heap allocation

This question may sound fairly elementary, but this is a debate I had with another developer I work with. I was taking care to stack allocate things where I could, instead of heap allocating them. He was talking to me and watching over my shoulder…
Adam
  • 24,261
  • 23
  • 72
  • 87
470
votes
10 answers

How can I explicitly free memory in Python?

I wrote a Python program that acts on a large input file to create a few million objects representing triangles. The algorithm is: read an input file process the file and create a list of triangles, represented by their vertices output the…
Nathan Fellman
  • 108,984
  • 95
  • 246
  • 308
467
votes
28 answers

Docker error : no space left on device

I installed docker on a Debian 7 machine in the following way $ echo deb http://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list $ sudo apt-get update $ curl -sSL https://get.docker.com/ubuntu/ | sudo sh After that when I…
user_mda
  • 12,733
  • 17
  • 62
  • 111
372
votes
6 answers

If a DOM Element is removed, are its listeners also removed from memory?

If a DOM Element is removed, are its listeners removed from memory too?
Julian Krispel-Samsel
  • 6,792
  • 3
  • 31
  • 40
340
votes
20 answers

How to get the size of a JavaScript object?

I want to know the size occupied by a JavaScript object. Take the following function: function Marks(){ this.maxMarks = 100; } function Student(){ this.firstName = "firstName"; this.lastName = "lastName"; this.marks = new Marks(); } Now I…
anonymous
291
votes
2 answers

What is the purpose of std::launder?

P0137 introduces the function template std::launder and makes many, many changes to the standard in the sections concerning unions, lifetime, and pointers. What is the problem this paper is solving? What are the changes to the language that I have…
Barry
  • 247,587
  • 26
  • 487
  • 819
1
2 3
99 100