Stack Exchange Network

Stack Exchange network consists of 175 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-usage]

The tag has no usage guidance.

5
votes
1answer
191 views

When does a JSON object become a burden on memory? [closed]

I'm developing a single page application where the first page contains the subjects and the next one contains items of the chosen subjects. The items are stored in a JSON object fetched from the ...
-4
votes
2answers
121 views

How the value of the integer variable is stored in a memory by bytes/bits?

In C program I'm doing below stuff int x = 4; Let us assume integer has 2 bytes in this case. So my question here is the variable x will hold two bytes that mean 16 bits. So here how the value 4 ...
4
votes
2answers
203 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 ...
0
votes
1answer
113 views

In what other locations besides infinite streams and infinite lists is memoized lazyness useful?

Haskell is one of the few non-strict languages out there. In his paper Why Functional Programming Matters, John Hughes uses (memoized) lazy evaluation (as well as higher-order functions) to implement ...
106
votes
15answers
14k 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 ...
-1
votes
1answer
128 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 ...
2
votes
2answers
675 views

How do I avoid increased memory consumption by browser and performance degradation when dealing with many records?

In my MVC 5 web application there are many instances in which users will require to view thousands of records within grids, now I managed to get around many performance related issues by utilising the ...
4
votes
1answer
832 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
117 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 ...
-5
votes
1answer
143 views

Is this a legit question? [closed]

I see an interview question thats goes like this: Assuming you have an array with numbers 1 to N. Where N is at most 32,000. This array may have duplicates and you do not know what N is. With, 4KB ...
0
votes
1answer
49 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
1answer
106 views

Algorithm for graphing heap data from server memory, over long period of time

Right now I am collecting memory information on a node.js server every 100 seconds. I want do display the memory usage info as a graph on the front end. const mem = { heapTotals: [], heapUseds: []...
0
votes
3answers
305 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 ...
6
votes
6answers
470 views

Why is accessing elements of a huge dynamically allocated structure a lot slower than a small dynamically allocated array in C++?

I am doing C++ programming in Ubuntu and really care about the efficiency of my code. The computer that I work with has 32 GB of RAM and the compilation is done with the C++11 option. I noticed that ...
6
votes
3answers
972 views

C++ Dependency Injection vs Memory Usage

I have a hypothetical C++ code containing these two classes: Master: it's big, does a lot of things and is meant to have only one instance; Slave: quite the opposite. It can also do a lot of things, ...
1
vote
0answers
157 views

Constructing a stateful allocator using an interface

I have the following abstract class which implements the "Allocator" concept, using policies and traits to customize behavior: #define FORWARD_ALLOCATOR_TRAITS(C) \ typedef ...
1
vote
1answer
181 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 ...
0
votes
3answers
273 views

How often can we use garbarge collection in C# [closed]

I would like to use garbage collection several times after calling some external dlls. And I wonder how often can I do this, without causing problems to my application. I'm using the following codes ...
3
votes
3answers
854 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 ...
-1
votes
1answer
485 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 ...
3
votes
2answers
198 views

How do I debug memory issues on a shared server?

I have an ASP.NET web site on a shared server. The site is mainly used to house some WCF services that are used by a desktop application. We had a problem in that the server stopped responding, and ...
1
vote
0answers
136 views

Caluclate needed heap size needed for serialization

In my current Java EE project I've got a quite common task: Load objects from database using Hibernate, transfer them in another object structure (based on a XSD) and serialize it using JAXB. To ...
5
votes
0answers
781 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
2answers
204 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 ...
1
vote
2answers
242 views

How do I best store a value with multiple keys?

I need to store two 32-bit numbers in a way that is quickly accessible and as storage space efficient as possible. My keys are a combination of the following two values: port: 0 - 29 vlan: 1 - 4095 ...
2
votes
1answer
675 views

How to manage multiple views in a single page JavaScript Application without a 3rd party library [closed]

I am building a JavaScript application that makes AJAX requests to a PHP API Back-end to load JSON data for different views. The app UI consist mainly of a left sidebar menu which has items loaded ...
1
vote
1answer
100 views

De facto weak reference centralized object storage

In a PHP CLI software, we are facing serious memory leakage due to a lot of rotten code, both accumulated in our own software and third-party plugins for our software. Currently, the object ...
2
votes
4answers
5k views

Does it make sense for an object declared on the heap to declare one of its members on the heap?

I recently reviewed some C++ code written by a fellow student, and he did something I wouldn't think is necessary. In main(), he creates a class object on the heap with the new operator. Then he ...
2
votes
0answers
69 views

What's the most practically efficient way to store differences in adjacent matrix values?

I am implementing a certain algorithm that works like this: Create a closed contour (list) of elements in a matrix, where closed means that the last element is adjacent (by row, column) to the first. ...
2
votes
1answer
86 views

Fast and memory-optimized checking for values in database using php

I have a function to generate n random string with the same length, making sure there isn't any duplicates, and then saves them to the database. Right now, to speed things up, first I get all the ...
0
votes
1answer
578 views

Copy a function in memory to a different location and be able to run it from the new location

How'd I go about copying a function in memory to a different location and be able to run it from the new location in C++? I thought maybe memcmp would work, but I'm not sure how I'd go about running ...
-1
votes
2answers
89 views

What programming environments can be used to illustrate and benchmark the unoptimized space complexity of an algorithm?

What programming language along with implementation and compiler can I use to study the pure, unoptimized space complexity of an arbitrary algorithm? And what methods can I use to do so? For example,...
12
votes
5answers
1k views

Is there a drawback at allocating a huge amount of the stack for a single array in an embedded system?

I usually have no problem deciding whether some data has to be global, static or on the stack (No dynamic allocation here, so no use of the heap). I have also read a few Q/A such as this one but my ...
0
votes
3answers
215 views

Is it possible to reason about memory just by looking at type signatures?

If I have pure functional programming language with* very very smart optimization* proccess, is it possible to reason about memory usage, just by looking at type signature? add :: Int -> [Int] -&...
1
vote
1answer
201 views

Memory usage on Creating a Travian like map and 441 Buttons on a page

I'm creating A Map like Travian on Xamarin forms My map is something like 5000*5000 The way I want to do that is to load part of the map (21*21) of the big map where the current village is the ...
14
votes
6answers
9k views

How important is memory alignment? Does it still matter?

From some time now, I have searched and read a lot about memory alignment, how it work and how to use it. The most relevant article I have find for now is this one. But even with that I still have ...
6
votes
2answers
1k views

Memory usage of JavaScript string type with identical values

JavaScript string type is immutable, but does it mean identical strings will share memory? Say two strings are created in complete different places, will a modern JavaScript engine be smart enough to ...
1
vote
2answers
831 views

How do Virtual Machines allocate memory?

If I want to allocate a struct in C, #include<stdio.h> typedef struct container { int i; } Container; int main() { Container *ptr_to_container; ptr_to_container = (Container *) ...
2
votes
1answer
131 views

Memory allocation while calling a sequence of functions in Java

A method getReminder takes two integers and returns r = (a^5)%m. This method relies in two BigInteger numbers BigInteger.valueOf(a).pow(5) and BigInteger.valueOf(m), but BigInteger was never declared....
3
votes
2answers
5k views

memory allocation in C while calling function

I have a really basic question regarding how memory gets allocated in a code written in C. Let's say that I have something like this: int pointless(int a); int main(){ int num1,num2; num1=...
1
vote
2answers
605 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 ...
2
votes
1answer
958 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 ...
4
votes
0answers
147 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 ...
0
votes
2answers
118 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 ...
12
votes
4answers
10k views

How much stack usage is too much?

Lately when I've been writing C or C++, I'll declare all my variables on the stack just because it's an option, unlike with Java. However, I've heard that it's a bad idea to declare large things on ...
23
votes
1answer
8k 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
891 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. ...
-4
votes
4answers
303 views

Splitting one class into subclasses to save memory

Suppose that you describe programs, which have a lot of AssignmentStatement(target, /*value*/Expression). There are other statements, like if-statement and for-statement and all of them may have ...
5
votes
1answer
615 views

In SPA what happens in terms of memory and performance when user hops across all the pages?

Imagine a humongous web aplication built using Single Page Application framework such as AngularJS. With its each route it downloads a couple of HTML template files. Each of these template files ...
66
votes
8answers
6k views

If I need to use a piece of memory throughout the lifespan of my program, is it really necessary to free it right before program termination?

In many books and tutorials, I've heard the practice of memory management stressed and felt that some mysterious and terrible things would happen if I didn't free memory after I'm done using it. I ...