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

35878 questions
3704
votes
61 answers

How can I create a memory leak in Java?

I just had an interview where I was asked to create a memory leak with Java. Needless to say, I felt pretty dumb, having no idea how to start creating one. What would an example be?
MatBanik
  • 26,356
  • 39
  • 116
  • 178
1018
votes
16 answers

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

How do I get the size occupied in memory by an object in Python?
user46646
  • 153,461
  • 44
  • 78
  • 84
883
votes
31 answers

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

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 "wrong" Depending on how you look at it, ps is not…
ksuralta
  • 16,276
  • 16
  • 38
  • 36
875
votes
10 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
  • 9,060
  • 5
  • 19
  • 25
833
votes
10 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
  • 27,211
  • 13
  • 45
  • 46
770
votes
36 answers

Fatal Error: Allowed Memory Size of 134217728 Bytes Exhausted

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
  • 7,741
  • 3
  • 19
  • 8
750
votes
11 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
  • 15,976
  • 4
  • 18
  • 14
709
votes
32 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
  • 18,148
  • 27
  • 82
  • 145
682
votes
28 answers

How to determine the size of an object in Java

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.
  • 31,911
  • 17
  • 52
  • 61
597
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
  • 122,701
  • 101
  • 260
  • 319
544
votes
24 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
  • 25,966
  • 23
  • 76
  • 87
433
votes
22 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
425
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
  • 7,512
  • 3
  • 33
  • 40
360
votes
3 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
  • 286,269
  • 29
  • 621
  • 977
351
votes
9 answers

How do I profile memory usage in Python?

I've recently become interested in algorithms and have begun exploring them by writing a naive implementation and then optimizing it in various ways. I'm already familiar with the standard Python module for profiling runtime (for most things I've…
Redwood
  • 66,744
  • 41
  • 126
  • 187
1
2 3
99 100