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

4
votes
1answer
777 views

Redux memory consumption

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
76 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. ...
50
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 ...
-3
votes
1answer
70 views

How are things like lists allocated in memory? [closed]

When I read about amortized analysis it mentions how when a list is full it has to re-allocate a list of even bigger size and copy all the elements over. My questions: Where is the list stored in ...
30
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
2answers
177 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 ...
2
votes
4answers
169 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 ...
2
votes
2answers
217 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
129 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
201 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
132 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 ...
1
vote
3answers
93 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
1answer
121 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
51 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, ...
2
votes
2answers
55 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
164 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 ...
5
votes
2answers
670 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 ...
19
votes
3answers
1k 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 ...
1
vote
3answers
134 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 ...
12
votes
2answers
462 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 ...
1
vote
2answers
170 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
47 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
295 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
136 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
294 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
99 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 ...
0
votes
1answer
109 views

Memory Limit of a Single Program and mmap

If one has a 32 bit machine, a single program cannot address more than 2^32 bytes, or 4 GB. Would making use of mmap() allow one to exceed the 4 GB limit?
3
votes
1answer
394 views

Are there real world examples demonstrating reasonable performance improvement by using move semantics?

(I've asked a similar question on SO but unfortunately it might not be proper, so I also put here; please kindly point out if you think it's a duplicate.) I've heard many words about the move ...
1
vote
5answers
4k 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 ...
2
votes
1answer
276 views

How can C++ make it possible to use dynamic container classes even in embedded systems?

How can C++ make it possible to use dynamic container classes even in embedded systems? Background info: I've been working with PIC (C) and AVR (C++) processors and at the moment (PIC C) I'm ...
1
vote
1answer
124 views

Translation Lookaside buffer - Lookup By Page Size

I am having a hard time finding documentation that explains precisely how the various TLB caches are used in modern processors. Most modern processors have separate TLBs for code/data. That in itself ...
115
votes
9answers
13k views

When is it a good idea to force garbage collection?

So I was reading a question about forcing the C# garbage collector to run where almost every single answer is the same: you can do it, but you shouldn't - except for some very rare cases. Sadly, ...
0
votes
0answers
31 views

Cache Memory Vs Main Memory [duplicate]

Why is the access time of the cache memory lesser than the access time of the main memory? I have tried looking at the sites as - tutorialspoint.com, education-portal.com etc. I know that the ...
3
votes
2answers
229 views

Place variables frequently used by the same function on the heap?

Say that I have the following situation: void myFunc() { int x; //Do something with x } "x" is placed on the stack which is no doubt fast. Now, "myFunc" is called very frequently, lets say ...
3
votes
2answers
722 views

Best practice for uploading large file, previewing, and editing before saving to database?

I am allowing users to upload a relatively large .csv file (about 1MB) - it will contain thousands of records that each represent one of my business objects. I want the users to upload the file and ...
0
votes
1answer
128 views

Architecture question about data migration

I'm facing a new enterprise project in Java about data migration. I did one of them in the past, now I want to do a better work and I think I need your considerations. So, let's me explain the ...
1
vote
1answer
790 views

Relation between cache line and memory page

If I am correct, a page in a main memory is the smallest unit unit for transfer data between the main memory and an external storage device, such as a hard disk. A cache line of a main memory is the ...
0
votes
1answer
2k views

Facing MemoryError in Python

I wrote a program to find prime factors of a number. When I give a large number(600851475143) as input, MemoryError pops up. Below is the code: def fact(a): factors = [] for i in ...
2
votes
1answer
588 views

Understanding memory update propagation in x86/x86-64 CPU L1/L2/L3 caches and RAM

I'm trying to understand in a general sense how L1/L2 (and now L3 caches) are updated and how the updates are propagated in a multi-core x86/x86-64 CPU to the other cores and eventually RAM. Assuming ...
9
votes
5answers
257 views

Correctly disposing objects upon server termination

I am working on a large C++ project. It consists in a server that exposes a REST API, providing a simple and user-friendly interface for a very broad system comprising many other servers. The codebase ...
0
votes
1answer
1k views

Calculating physical address given only an offset for my process

Learning about virtual memory with an program assignment. Currently this is what I have: Main memory has 60 bytes and virtual memory another 60 bytes. The size of a frame/page is 10 bytes. So there ...
0
votes
3answers
313 views

Can a process that needs 15 MB run given a machine with 10 MB of physical memory and 10 of virtual?

So there is physical and virtual memory. Let's say we have 10 MB physical and 10 MB virtual. There is also paging. As far as I get it, paging basically splits physical and virtual memory into slots ...
1
vote
1answer
78 views

Is it possible to quickly change an array declared on the stack to one declared on the heap

I have about 5000 lines of code which manipulates a large array in C++. The problem is that when I try to make the array even larger i.e. A[10000][10000], the gcc compiler throws me a segmentation ...
0
votes
2answers
218 views

memory needed to store a function in javascript

I have been using sizeof.js to investigate the size of various objects in javascript. It appears from this that the size of a function is essentially zero bytes, regardless of how many instructions ...
7
votes
2answers
266 views

Autoreleasing objects in Reference Counting Systems

I'm experimenting a bit in C and I'm trying to implement my own Reference Counting System. I've mainly worked with Objective-C in the past but AFAIK autoreleasing objects is something that is unique ...
6
votes
1answer
238 views

Does assigning NULL in a GC'ed Environment have similar effects to using free()?

I was just writing a function (in C# in this case) that stored huge amounts of data in a local variable early on in the code, let's say at 5% of the functions code. After that point, the data in this ...
1
vote
2answers
310 views

How does the CPU access the values of stack-allocated variables? [duplicate]

Consider the following C++ function: void doStuff() { Thing thingA; Thing thingB; thingA.doSomething(); // .. etc } During the execution of this function, variables thingA and ...
0
votes
1answer
574 views

JVM memory and zero-copy (de)serialization

I am trying to understand the JVM memory model. In particular, I would like to understand whether it would be feasible to have zero-copy (de)serialization libraries, such as Cap'n Proto or ...
3
votes
2answers
5k 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 ...
0
votes
1answer
178 views

What effect does using multiple childViewControllers views inside a ContainerViewController have on memory?

I have three childViewController views inside my ContainerViewController and these three views are inside a horizontal scroll view. My intention is to build an app that has a custom camera on one ...