Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [memory]

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.

0
votes
2answers
88 views

How did old OSs create or expand a segment in memory without issues?

On an 8086 CPU before the flat memory model had been adopted, when the OS wanted to create a new segment for a process, how did it know what virtual memory ranges were already covered by existing ...
-1
votes
2answers
106 views

Does the OS (kernel) have access to the physical memory

I know that there is a hardware in CPU, the MMU which takes care of mapping a given address to physical address. For example: int *ptr = 0x12345 Will make a pointer to my process address of 0x12345 ...
-2
votes
0answers
64 views

Handling OutOfMemoryException inside loop

I have loop with method inside her. In one iteration method throw OutOfMemoryException (c#). I want to log that event and to continue with looping and i don't want to stop my application because of ...
8
votes
2answers
640 views

Why is DateTime.Month an int?

In C#, the DateTime property Month has a type of int (a 32 bit signed integer) yet its' range will only ever be 1-12. What are the reasons the C# team chose int over a smaller numeric type such as ...
4
votes
2answers
199 views

Do operating systems implement techniques to ask programs to give up non-vital memory in times of shortages?

When a system is running low on available memory can it ask programs in general to give up any non-vital memory without shutting down. Like a process signal which causes the processes to yield any ...
-3
votes
0answers
64 views

How does an Operating System gets allocated its first memory space [duplicate]

Going through osDev.org, I managed to write a small kernel that outputs a memory address, similar to this: #include <stdio.h> int main() { size_t a = 2; size_t *p = &a; printf("...
-3
votes
2answers
174 views

How are memory addresses created?

#include <stdio.h> int main() { size_t a = 2; size_t *p = &a; printf("%p\n", p); } The above code will print the memory address of a. I understand that within an OS, this ...
1
vote
2answers
237 views

How to process huge amount of data with limited processing ressources? [closed]

I receive daily from an external source a very large amount of data (around 250GB with 260 million rows of fixed width text) distributed over 5 text files. I am writing a Java application that should ...
2
votes
4answers
178 views

Is an Array Index content stored in one memory address?

Assume in C we have the following array of one item: int a[] = {2000}; 2000 in binary would be: 11111010000 If each memory address can hold 1 byte (8 bits) of data, then howcome in some tutorials, ...
106
votes
14answers
13k views

When to optimize for memory vs performance speed for a method?

I recently interviewed at Amazon. During a coding session, the interviewer asked why I declared a variable in a method. I explained my process and he challenged me to solve the same problem with fewer ...
2
votes
1answer
79 views

If you can store BigInts in a more optimal way than an array

This suggests just storing BigInts as an array: // n = -123 var n = { sign: -1, digits: [3, 2, 1] }; However, if you have "big ints", that array will get large: var n = { sign: -1, ...
2
votes
3answers
158 views

How to align on both word size and cache lines in x86

From what it sounds like, a 64 bit processor means aligning to 64 bits, which means if you have unicode utf-8 stored in there, each 8-bit chunk would take up 64 bits of space. That doesn't really make ...
-1
votes
1answer
124 views

Executing an algorithm constantly on slow and fast machine

Is it possible to create an algorithm that will execute at the same rate and speed on faster and slow computers. What i mean is, i have a year 2000 desktop that can run a certain computational ...
3
votes
1answer
209 views

Why do we need to specify the type of data a pointer will hold, if all pointers are the same [duplicate]

Why do we need to specify the type of the data whose address, a pointer will hold, if all pointers are the same. Since all pointers store addresses. Also, the amount of space a pointer will require in ...
0
votes
1answer
102 views

Erlang: Memory implications of passing around large objects in/to functions

Is there a memory penalty to passing around large objects (like an entire http request, or the blob contents of an uploaded file) between functions within the same (Erlang) process? It is my ...
1
vote
1answer
47 views

Linked-list iteration patterns

If you have a linked-list, where the items are not necessarily close to each other in memory, wondering if it is (in general) better/worse/no difference to do the following. Say you want to iterate ...
2
votes
1answer
193 views

Algorithm for efficiently allocating memory

Given the following constraints: No multithreading. No care about hardware cache utilization. Wondering what a reasonably optimal memory allocation scheme would look like. From my limited knowledge,...
0
votes
1answer
48 views

Question about memory handling of trees and certain sorts on large data sets.

If data structures such as trees and certain sorts(quick sort, merge sort) work using recursive algorithms and recursive algorithms take up a lot of memory space in the stack and can only work on a ...
0
votes
2answers
250 views

What is the safest practice in handling QWidget pointer lifespan in a QObject oriented environment?

Consider the following constructor: NetworkTools::NetworkTools(QObject *parent) : QObject(parent) { view = new QWebEngineView(); view->setParent(parent); // Produces an error, shown below. ...
0
votes
2answers
199 views

copying of memory vs pointer to memory in real time systems

While working in a multi-threaded environment, then data sharing seems to be a good option to pass data between threads. While working with real time systems it is apparently advisable to go with ...
1
vote
0answers
164 views

How does the BIOS detect the size of installed memory? [closed]

I'm writing a little toy operating system using a mix of C and Assembly (It's not meant to be good/fast, just meant to learn from). I know that I can issue an interrupt (I think it's INT 0x15) to ...
0
votes
3answers
278 views

Extending the concept of Lazy Loading, to also unloading

A system that sometimes will need to use a pretrained machine learning model. That model is about 10Gb on disk, and when loaded uses about 10Gb of RAM. Loading it from disk takes a nontrivial amount ...
0
votes
3answers
473 views

Memory segmentation - stack, heap, etc.?

So memory segmentation can be done with or without paging. I always hear people talking about stack and heaps when discussing something memory related in C++. However, what I do not get is that if the ...
-4
votes
1answer
76 views

How was memory allocated in Windows 9x compared to Windows 10 ?

I heard rumours that when a new program is executed in Windows 9x, that app had to specify how much memory it needs to allocate beforehand. How is this different in Windows 10 ?
2
votes
1answer
136 views

How do peripherals decide which address to use in memory-mapped I/O?

I've been reading about how memory-mapped I/O actually works and I cannot understand how the system assigns an address or address space to a specific device. Let's say I had two devices that I wanted ...
4
votes
2answers
193 views

Endianess ARM Assembly Confusion

I'm writing code using arm assembly language for college and the I'm really confused about endianess. The default should be little endian but I'm sure the test string has been stored big endian. The ...
-2
votes
1answer
657 views

First Fit Algorithm Memory Allocation

I am currently reviewing memory partitions and I have a problem that is really confusing me. Suppose you have 5 memory partitions: 100K, 500K, 200K, 300K, and 600K. Also suppose you have 4 ...
3
votes
3answers
1k views

What does “address space” means when talking about IO devices?

The following quote is from this page: While some CPU manufacturers implement a single address space in their chips, others decided that peripheral devices are different from memory and, ...
4
votes
1answer
1k views

How does the Base Address Registers (BARs) in a PCI card work?

I am trying to understand how the Base Address Registers (BARs) in a PCI card work, this is how I think they work: Each function in a PCI card have 6 BAR fields, and each BAR field is 32-bit in size. ...
0
votes
1answer
166 views

When is return-value optimization used? [closed]

In the code snippet below, I have a class that holds a vector, and a getter to access it. When I compile my code with optimizations turned on, I would have expected that the call to get_value() would ...
2
votes
1answer
142 views

What does “data bus control” mean?

This video mentions the following: What does it mean for the DMA controller to be granted the data bus control, does that mean the CPU cannot use the bus to access memory and IO devices until the DMA ...
-1
votes
1answer
112 views

Help With Memory Mapped I/O and Hardware Interrupts for Virtual Machine

I've been working on a 24-bit virtual machine to help me learn more about computers and programming in general and was hoping to find a bit more information on memory mapped input/output and hardware ...
1
vote
1answer
179 views

What would be a mathematical rigorous definition of a memory address space?

What is the exact definition of a memory address space? Is it correct to name the set of all the numbers from 0 to the highest addressable byte the definition of an address space? EDIT: I would like ...
3
votes
3answers
777 views

Is O(log n) for memory management considered slow?

I am talking about single thread general purpose memory allocation/deallocation from a global 'heap' as e.g. every C programmer knows in the form of malloc()/free(). I can't recite the actual title ...
-2
votes
1answer
275 views

Why is it possible to access an array out of bounds with negative indexes much further than with positive indexes?

I have written two small programs in which I declare a very small array. Then I try to access values out of bounds. The interesting thing I noticed that when I try to decrement the index I can ...
25
votes
3answers
6k views

Why does a long int take 12 bytes on some machines?

I noticed something strange after compiling this code on my machine: #include <stdio.h> int main() { printf("Hello, World!\n"); int a,b,c,d; int e,f,g; long int h; ...
1
vote
1answer
115 views

What architectures have “weak” memory models?

I'm a long-time Java programmer familiar with the Java Memory Model. I'm starting to learn C#, and based on what I've learned so far, the C# memory model seems to be very similar to the JMM. This ...
-4
votes
1answer
114 views

Memory bit address

I am having trouble to understand the following question for my Computer Architecture assignment. Consider a system that has a direct-mapped cache that contains a total of one megabyte; each line ...
5
votes
0answers
708 views

Best Practices For Writing Memory Efficient CSS

What are some best practices for writing memory-efficient (for the lowest peak memory usage) CSS? I realize this is a broad question, so I have broken it down into two main categories: What are 'do's ...
3
votes
1answer
195 views

How can I efficiently implement batch allocation in a freelist?

I've been implementing Andrei Alexandrescu's allocators as an exercise, but I've gotten stuck on his Freelist. Andrei's Freelist looks something like this: template<class BaseAllocator, std::...
-5
votes
1answer
261 views

How to convert a logical address to a paging system

ive had a look around and I cant seem to find an answer or how to work out this question, its a tutorial question for my operating systems course and ive looked through the notes that come with the ...
3
votes
0answers
127 views

C#: simulate PostScript memory allocation

I'm working on a PostScript interpreter in C#. PostScript has memory management. It has virtual memory (VM). It also has objects. Two types of objects: simple and composite objects. Composite ...
3
votes
2answers
194 views

Protecting Structure from corruption

I am developing a safety critical embedded system and I am programming in C. We have a set of const structure declared in memory and they hold some critical data. I want to make sure that any of ...
6
votes
8answers
1k views

Strategies for implementing memory leak detection [closed]

What strategy would you use to detect memory leaks? I was asked this question in an interview that was mostly focused on C++, and couldn't find an answer. I said that there are tools that do it and ...
3
votes
1answer
287 views

Is global state evil if it doesn't change behavior?

I have a library in C where the API uses "objects" to interact with the application. These "objects" are opaque pointers that are created, destroyed, and modified via API calls. These "objects" do ...
3
votes
2answers
816 views

Insertion sort vs Merge sort - memory access

I am a computer science sophomore doing a data structures and algorithms course. My professor said that insertion sort requires random access, while merge sort does not. According to him, the ...
3
votes
1answer
810 views

Purpose of Segmentation and Logical Addresses in 8086

In 8086, mapping of logical adderss to physical address is done with the help of segmentation. Segment registers : offset, and you get the physical location in a 2^20 byte RAM, even though you have 16 ...
20
votes
3answers
5k views

Professional way to produce a large problem without filling up huge arrays: C++, free memory from part of an array

I'm developing a physics simulation, and as I'm rather new to programming, I keep running into problems when producing large programs (memory issues mainly). I know about dynamic memory allocation and ...
-4
votes
2answers
664 views

Proper way to implement a “dynamic array of non-default-constructible objects”

As many other questions and answers already stated, there is no syntax in C++ which allows you to declare and fill a dynamic-sized array with non-default constructible objects. Obj* array = new Obj[...
1
vote
3answers
529 views

What value does the byte pointed by null pointer have?

I know that long time ago computer scientists decided to treat all pointers to memory cell of address 0 as NULL. However, the memory cell at that address does exists after all, right? In that case, ...