Memory refers to the physical devices used to store programs or data on a temporary or permanent basis for use in a computer or other digital electronic device.

learn more… | top users | synonyms

18
votes
4answers
5k views

Debugging memory corruption

First off, I do realize this is not a perfect Q&A style question with an absolute answer, but I can't think of any wording to make it work better. I don't think there is an absolute solution to ...
0
votes
1answer
27 views

Value addresses of functions

I'm reading Yung-Hsiang Lu's book, Intermediate C Programming, and I'm working through the chapter on stack memory. When defining the value address he provides this code example: int f1(int k, int m) ...
-1
votes
0answers
127 views

Cannot allocate very large memory blocks even though I'm compiling as x64 [closed]

Running on 64-bit Windows and compiling my code with Visual Studio 2015 in 64-bit mode, when I attempt to allocate large amounts of memory (e.g. 0xff_ffff_ffff bytes, or just under 1TB) the ...
1
vote
1answer
102 views

Static memory idiom

I am on a micro controller (which means I can only have static memory allocation) and I am trying to work with inheritance..... Suppose I have a abstract class Image and an abstract class Font. An ...
2
votes
1answer
204 views

When to malloc and free?

Valgrind does not report a memory leak during my actual usage, only during my scripted test that I scripted with a shell script to test my own shell. I found that I didn't have to use malloc every ...
1
vote
2answers
126 views

Should I be using IDisposable here, to properly manage memory?

Background I have an object that represents a test procedure that I need to run on a product. This object may be used multiple times during run-time, depending on how many times the user elects to ...
77
votes
6answers
13k views

Why are floats still part of the Java language when doubles are mostly recommended instead?

In every place I've looked, it says that double is superior to float in almost every way. float has been made obsolete by double in Java, so why is it still used? I program a lot with Libgdx, and ...
1
vote
5answers
6k views

How to share memory between applications written in C/C++

I'm going through a program written in C/C++ for control in robotics. Basically, three different programs run at the same time, and they communicate via shared memory. Google-ling around I found ...
51
votes
5answers
10k views

Can the “level 256 bug” in the game of Pacman be considered an unhandled segfault?

I am trying to explain segmentation faults to someone, and I was thinking about the level 256 kill-screen in Pacman, and how it's triggered by integer overflow, and how similar the behavior is to the ...
2
votes
1answer
76 views

When should I worry about freeing objects from memory in Python?

I've been reading a few different guides and tutorials, as I am interested in learning some best practices of programming. I was reading the How to be a Programmer guide, and there is a section about ...
3
votes
2answers
545 views

Purpose of Base Address?

What's the purpose of a base address in an executable? For example, in Microsoft Visual C++'s linker, you can set a base address, or use the default of 0x1000000. But with virtual memory, why would a ...
3
votes
0answers
110 views

Laissez faire memory management [duplicate]

I noticed that various scripting language interpreters leak memory even for very simple programs, like the canonical "Hello world!" program. To illustrate the problem with examples: Perl 5.22 leaks ...
25
votes
8answers
4k views

Is it possible to statically predict when to deallocate memory---from source code only?

Memory (and resource locks) are returned to the OS at deterministic points during a program's execution. The control flow of a program by itself is enough to know where, for sure, a given resource can ...
0
votes
2answers
90 views

Does storing a value in a variable uses more RAM than using it directly?

I mean, does something, for example in C#, like String test = "Test"; txtCtrl.Text = test; consumes more RAM than just txtCtrl.Text = "Test"; ? As it's said, a variable is a reserved space in ...
5
votes
3answers
7k views

When I create an object, is fresh memory allocated to both instance fields and methods or only to instance fields

I have a following class class Student{ int rollNumber; int marks; public void setResult(int rollNumber, int marks){ this.rollNumber=rollNumber; this.marks=marks; } public void ...
1
vote
2answers
96 views

Load to list in one loop and then process list in another or do it all at once

I have a dataset full of rows that I must initialize into myclass and then process. I am currently looping through each row in the dataset, initializing a new instance of myclass, then adding that ...
42
votes
6answers
15k views

Why is CPU cache memory so fast?

What makes CPU cache memory so much faster than main memory? I can see some benefit in a tiered cache system. It makes sense that a smaller cache is faster to search. But there must be more to it.
6
votes
1answer
1k views

Redux memory consumption [closed]

The Redux framework favors immutable state/pure function paradigm, which promotes creation of new state from the previous state in terms of the current action. The applicability of this paradigm is ...
2
votes
2answers
109 views

Code size overhead by including unnecessarily extra header files

I have a program which includes lots of header files but it do not uses all the header files. I have removed some of them although it is working fine. I did not notice any changes in the performance. ...
12
votes
7answers
2k views

Demonstration of garbage collection being faster than manual memory management

I've read in many places (heck, I've even written so myself) that garbage collection could (theoretically) be faster than manual memory management. However, showing is a lot harder to come by than ...
29
votes
5answers
5k views

If a number is too big does it spill over to the next memory location?

I've been reviewing C programming and there are just a couple things bothering me. Let's take this code for example: int myArray[5] = {1, 2, 2147483648, 4, 5}; int* ptr = myArray; int i; for(i=0; ...
2
votes
4answers
189 views

In a byte, each additional bit doubles the representable states, but does it double memory?

A friend asked me whether adding a single bit more memory doubles the amount of memory you have, as the bit doubles the amount of representable states. My brain got stuck thinking about it. Doubling ...
1
vote
3answers
96 views

Reading from Memory vs Performing an Operation [closed]

I'm learning to program microcontrollers and am trying to develop good habits: Suppose I have a set of values which can be calculated based on what is already in memory. As a general rule, is it ...
2
votes
2answers
191 views

Where is the class itself stored at runtime to be used as a reference

In C# or Java we find that the objects are stored on heap and their reference vars are stored on stack. But at run time where is the class definition stored to be used as a template for creating ...
63
votes
5answers
104k views

Stack and Heap memory in Java

As I understand, in Java, stack memory holds primitives and method invocations and heap memory is used to store objects. Suppose I have a class class A { int a ; String b; ...
7
votes
3answers
4k views

Custom heap allocators

Most programs can be quite casual about heap allocation, even to the extent that functional programming languages prefer to allocate new objects than modify old ones, and let the garbage collector ...
2
votes
2answers
345 views

Improving the efficiency of containers with dynamically allocated objects

This is not strictly related to C++ but its type system serves to illustrate the problem well. Assume: We have a generic template Container<T> (such as a std::vector<T>) which stores an ...
2
votes
2answers
259 views

Java Game. Preload objects and reuse vs create objects at runtime [closed]

I'm currently developing my first game in Java language. The game is an endless runner with obstacles to avoid and enemies to kill. Unfortunatelly im still not experience enough and many times im ...
6
votes
2answers
158 views

Does Time Complexity analysis factor for cache performance of an algorithm?

If I have an algorithm A. and it has fewer instructions than algorithm B. but performs worse on a CPU due to poor memory coalescing (and hence, poor CPU cache performance), does that factor into the ...
2
votes
1answer
203 views

Why is checking weird bit errors important in garbage collectors?

Here's a rough translation of a tweet by @xharaken. "Space rays hit computers and mess up the bits in the memory" "hardware bugs mess up the bits in the memory" such things almost never happen, ...
4
votes
3answers
186 views

In x86, where are the memory addresses of the values on the stack located?

Suppose I have a very simple C program that just does this: int i = 6; int j = 4; int k = 5; int a = i + j + k; Since i, j, and k are on the stack, they will be located relative to the stack ...
2
votes
1answer
220 views

Memory/cache performance in working with arrays in C

I've been toying with some array examples in C. I want to understand more about memory concepts, alignment, and cache. Especially on large arrays on heap. Sometimes I work on large images (extremely ...
-3
votes
1answer
71 views

dma allocation in kernel 4g patch theory [closed]

I was reading about that that old patch. The summary of that link is to create a 4Gb kernel space, instead of 1Gb by default. Since many dma capable devices can only access 32 bit addresses or 4Gb, ...
4
votes
5answers
1k views

Java memory management (thunks/lazyness)

If I want to create an infinite list of integers in Java like so: ArrayList<Integer> list = new ArrayList<Integer>(); for(int i = 0;;i++){ list.add(i); } I run out of memory. My ...
2
votes
2answers
64 views

Efficiently editing text files [duplicate]

I have been working with some fairly large text files containing about two million lines of text. I don't know the length of the content or the lines in advance, just the number of lines. I have been ...
2
votes
1answer
170 views

In garbage collecting languages (JavaScript), can I securely overwrite data?

Realizing that garbage collection and memory management is implemented differently in different environments for sake of simplicity this question will focus on JavaScript (either V8 or Seamonkey). I ...
12
votes
2answers
480 views

What uses does Smalltalk’s ‘become:’ have?

The become: message in Smalltalk causes one object to change into another, affecting all references to it. What uses does this language feature have? Does it get used in real code? Is it just a ...
13
votes
2answers
916 views

How important it is to fix memory leaks?

I found by Valgring that some GTK+ programs leaks memory. How important it is to fix those leaks? I mean, often those programs works very well but on the other hand, one can never be sure if one wants ...
8
votes
3answers
14k views

How can I monitor the JVM memory in a proper way?

I'm thinking of how we do JVM memory monitor in a low overhead way in production environment even under busy hour. Suppose I have two tomcat app server in production, load balance set up behind them. ...
5
votes
2answers
916 views

Foreach loop and variable initialization

Is there a difference between these two versions of code? foreach (var thing in things) { int i = thing.number; // code using 'i' // pay no attention to the uselessness of 'i' } int ...
20
votes
3answers
2k views

Why are C string literals read-only?

What advantage(s) of string literals being read-only justify(-ies/-ied) the: Yet another way to shoot yourself in the foot char *foo = "bar"; foo[0] = 'd'; /* SEGFAULT */ Inability to elegantly ...
2
votes
2answers
791 views

Methods to identify and resolve memory leaks in the JVM [closed]

As the data is migrated via the object level, there has been a slow upwards trend in memory usage. I can see the periodic gc activity, but the memory trend is still going up slowly. I have currently ...
1
vote
3answers
142 views

Pre-calculate values or not on Raspberry Pi

Say that you want to rotate something 360 steps 100 times. You now have a choise to pre-calculate 360 sin and cos values once and then use the stored values 100 times, or you can calculate sin and cos ...
0
votes
2answers
917 views

How are new[] and malloc implemented in Windows? [closed]

So when you call malloc or new [] from your C/C++ application, how does the CRT translate it into Windows API calls?
1
vote
2answers
289 views

What is a latency-bound and a memory-bound application in HPC?

I understand that in HPC hybrid systems, for instance a MIC architecture, main memory access is much slower than access to data in own cache or in the cache of another core. I read that HPC MIC ...
0
votes
2answers
68 views

Memory page - virtual or physical and relation to data types allocation?

I'm looking for a understandable definition of memory pages. Please help me clarify the following questions: Is a "memory page" always related only to a data chunk of virtual memory? Are physical ...
1
vote
1answer
367 views

Android & OutOfMemoryError: Possible causes besides memory leak?

In my application I keep receiving crash reports where the root cause is an OutOfMemoryError. The app is quite image heavy (I use Picasso for all the image loading) and also has a WebView component ...
0
votes
0answers
166 views

Class to manage EEProm Memory for microcontroller in .netMF

I've got a working driver to access the EEPROM chip, but looking for much better management and access of the memory. I've been racking my brain about what's the best or correct approach to do this. ...
5
votes
2answers
309 views

Does sun.misc.Unsafe give access to the system or just the JVM?

Please note: Although this question involves microcontrollers, it is at its core, a Java question, and so I believe it can be answered by any battle-weary Java guru. I stumbled accross this blog ...
0
votes
2answers
102 views

Should I set values using the return or by giving a reference?

Suppose I have a mouse position watcher, which should let the user extract the mouse position. Should the mouse position be set in the method and returned: Mouse_Position ...