Questions tagged [memory-usage]
The memory-usage tag has no summary.
103 questions
16
votes
6
answers
10k
views
Unstable output C++: running the same thing twice gives different output
So, the problem:
When I run the same C++ code in Visual Studio, with the same input and parameters, I get either the correct output, or an output that is completely messed up (99% of values go to zero)...
1
vote
0
answers
459
views
Implementing a memory efficient Abstract Syntax Tree
I am writing a compiler in C++ 20. I am looking for ways to improve heap memory performance. For example, I can compile a 36.8 MB source file that is just many repeating lines of:
let x0: string = &...
6
votes
2
answers
2k
views
How to get out of a memory usage problem of a .NET application?
As mentioned in some StackOverflow posts (like this one), I'm dealing with a difficult situation:
My company is developing some C# applications (being a client-server application). We have migrated ...
0
votes
3
answers
175
views
Should web applications have predictable worst-case resource usage?
Consider Mastodon as an example - basically open source Twitter. Tweets can be up to 500 characters long. Of course, since it's open source, you can modify it to allow longer tweets. Unmodified ...
-1
votes
1
answer
242
views
Better way to represent grammar symbols in C
I'm trying to build a simple compiler for a subset of the C language in C. To achieve this, I needed to figure out a way to represent the grammar symbols. Basically, each symbol can either be a "...
1
vote
4
answers
3k
views
Memory Alignment
I want to make sure I understand the concept referred to by alignment:
Is it just a way of making sure that you never have a non-integer number of words? The wikipedia page says in order for an access ...
3
votes
1
answer
104
views
Should small overhead count towards an upper memory bound or rather be ignored?
I have a memory pool class that manages memory objects of fixed sizes, a bit like a primitive malloc() that can only return memory blocks of a few predefined sizes and unlike malloc() is guaranteed to ...
-2
votes
1
answer
587
views
How to manually delete a std::vector in c++? [closed]
I have following code snippet
void func(int row,int n,std::vector<int>& buffer){
if(row>n){
return;
}
std::vector<int> new_buffer;
for(int elm : buffer){
...
8
votes
1
answer
702
views
Temporal logic as a programming language paradigm?
So I'm aware there's some degree of timing-based logic in existing programming languages, like threads and the sleep() function (and derivatives thereof), as well as events / delegates.
However, I was ...
-2
votes
1
answer
130
views
What memory cleaner software exactly do? [closed]
You must have seen them as applications on mobile devices and I've been using one on mac OS. I was wondering what exactly memory cleaner software do? Do they free up memory in both ROM and RAM? And ...
-4
votes
1
answer
106
views
Using only the Cache not the DRAM in a Program (USB to Ethernet) [closed]
I am reading some data from USB, do some packet processing and then send the result to the Ethernet port.
The USB ports are connected to an onboard USB Hub where it communicates with the ...
3
votes
7
answers
3k
views
Is it possible to update exactly 1 byte in RAM?
For example I have a static C++ array {'d', 'o', 'c', 's'}. And I have x86 architecture, with 32-bits length words.
I want to replace letter c with g. As far as I understand, when we make a read ...
1
vote
2
answers
397
views
How to create objects and allocate data only once in C++ to improve speed with octave .oct files?
I have been coding some octave .oct files lately (C++), and for my purposes speed is of the essence.
It seems to me that creating C++ objects (in general) can take some time. I was wondering if ...
-3
votes
1
answer
410
views
What programming languages besides Apple Swift & Objective-C use the Llvm compile-time Automatic Reference Counting exclusively for memory management?
Are there other general purpose programming languages besides Objective-C +ARC and Swift which target the llvm and use static compile time Automatic Reference Counting for memory management?
-2
votes
1
answer
1k
views
In C++ and GCC on Linux, is it possible to allocate memory to your swap space instead of your RAM?
I have a large hash, around 6 gigabytes that I load into memory. On my current laptop that I develop from, it really does a number on my system, causing massive amounts of lag while I try to go about ...
-2
votes
1
answer
181
views
How to profile a program for performance without a profiler?
This is a general question but with a specific use case. There is only a single and completely unaffordable profiler for the Xamarin framework. So this makes me wonder if there are some programming ...
1
vote
1
answer
188
views
How to eliminate transparent memory copy in runtime?
Despite various ways to scrub sensitive data in volatile memory (see Survive DSE or Zeroing buffers), programs tend to perform transparent memory copies (such as a Garbage Collection). The newly ...
0
votes
1
answer
185
views
How swap space works in this example?
Say I have total RAM memory of 1GB , HD of 10 GB with 250 MB swap space
Say I have two files(f1 and f2) each of 500 MB opened on my my laptop. Now both files are in memory and have consumed 1 GB of ...
2
votes
2
answers
576
views
Memory optimization of public methods in java
Does it optimize a program in java to declare methods private wherever they can be private or it doesn't change a thing and it's just a question of encapsulation? I was asking myself if declaring a ...
5
votes
1
answer
1k
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
2
answers
2k
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
2
answers
239
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
1
answer
212
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 ...
109
votes
15
answers
20k
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
1
answer
223
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
2
answers
1k
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 ...
5
votes
1
answer
7k
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
1
answer
459
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
1
answer
200
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
1
answer
64
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 ...
-1
votes
1
answer
158
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
3
answers
1k
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 ...
7
votes
6
answers
4k
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 ...
7
votes
3
answers
2k
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
0
answers
489
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
1
answer
249
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
3
answers
734
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
3
answers
2k
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
1
answer
2k
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
2
answers
420
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
0
answers
443
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
0
answers
1k
views
Best Practices For Writing Memory Efficient CSS [closed]
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
2
answers
444
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
2
answers
603
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
1
answer
1k
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
1
answer
143
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
4
answers
14k
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 ...
3
votes
0
answers
111
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
1
answer
124
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
1
answer
2k
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 ...