Tagged Questions

Memory management is the act of managing computer memory by allocating portions of memory to programs as well as freeing memory so that it can be re-used.

learn more… | top users | synonyms (1)

0
votes
1answer
42 views

Use parent class to declare a child object or how compiler allocates memory

I'm working with C# and .NET Framework 4.0 and Windows Forms. On my project I have three custom objects that inherits from MyControl class (...
5
votes
2answers
195 views

Reading, counting, and processing integers from a text file

The following code reads a .txt file that contain only numbers. Read the first one, create a dynamic array and put the other numbers on it, made some procedures and in the end write a file with the ...
11
votes
3answers
387 views

Random permutation of int[] and ArrayList<Integer>

I wrote a simple program using int[] and ArrayList<Integer> which aims to get a random permutation output between 1 to 10, ...
0
votes
0answers
47 views

Freeing a binary tree data structure in C

I have this function that I hope to be a good alternative to the recursive (thus performance expensive) approach. ...
1
vote
2answers
43 views

Deserialize JSON Strings Directly into Models?

I have Ruby models which are populated from the responses of API calls in the following way: JSON.parse converts the response to a ...
1
vote
2answers
101 views

std::vector of pointers with the rule of three

I have a class that has a std::vector of pointers, I'm NOT going to give any of those pointers to objects outside of it, I mean, I'm not going to share the ...
1
vote
2answers
69 views

Backing up an entire website with PHP

I'm attempting to backup lots of website using this php code. The script basically goes through the whole public_html directory and adds all the folders and files recursively and zips them. Here's ...
7
votes
0answers
43 views

Wrapping types with alignment requirements

Visual Studio 2013 still doesn't support the alignas keyword in C++11. This causes some problems with alignment of types in various situations. Thankfully the ...
5
votes
1answer
40 views

Converting decimal integers to a string representation in an arbitrary base between 2 and 26

This code takes an integer and returns a string representing the value in a different base. The value for the base can range between 2 and 26. I have had someone already look over this code and they ...
6
votes
2answers
82 views

Vector backed by memory pages

The purpose of this class is to wrap a std::vector in a class so that never a new object is added. We don't allocate a new object on the stack but we trying to fit ...
6
votes
4answers
222 views

Simple resizable array

In some (lower-level) parts of my codebase I often have the need to allocate resizable array storage for certain objects, that usually are not default-constructible. I created a simple class using ...
5
votes
1answer
93 views

My iPod is slower than my iPad

Many of the variables in my 2D mining game were declared as constants like so: DWConstants.h ...
1
vote
1answer
28 views

Implementation of Vertex Similarity algorithm (Blondel's Similarity Measure)

I am implementing the vertex similarity algorithm in this paper. The adjacency matrices I will be dealing with, however, will be very large, on the order of 30k vertices (I provided sample matrices in ...
2
votes
1answer
54 views

Perfect elimination ordering and high memory usage

The following code calculates a perfect elimination ordering in a special case in Haskell. I am less worried about its correctness than its high use of memory. The following code runs out of memory ...
4
votes
3answers
135 views

Implementing an ArrayList

I implemented ArrayList functionality in C as follows: ...
2
votes
2answers
72 views

RAII and code duplication in constructor/destructor

I have a class hierarchy similar to this: ...
3
votes
1answer
67 views

Program that handles program options

I'm using boost::program_options to parse input from the user. However, while the standard library makes this an easy task to do, it's causing an (in my opinion) ...
10
votes
2answers
275 views

Simple key-value store in C, take 2

Followup to Simple key-value store in C. Response to previous reviews You may want to hide the KVSstore structure Done. Add a comparison function pointer to KVSstore. If this pointer is ...
5
votes
2answers
98 views

Simple key-value store in C

I needed a simple key-value store. Here's what I came up with. Usage Use kvs_create and kvs_destroy to create stores and clean ...
3
votes
3answers
53 views

Hexadecimal to string without C++ standard library functions

For the purposes of this code review, I will use the standard library, but pretend that <cstddef> is <stddef.h>, ...
7
votes
4answers
190 views

Memory usage in Reversi board state

I'm coding a Reversi game, with an artificial intelligence using the MinMax as the search algorithm. My concern is that (most) search algorithms needs to store a lot of instances of "states", in my ...
3
votes
1answer
72 views

Comparing different string-matching functions

Here is a problem came from codingbat: Given 2 strings, a and b, return the number of the positions where they contain the same length 2 substring. So "xxcaazz" and "xxbaaz" yields 3, since ...
9
votes
5answers
411 views

Static factory function and lifetime

I'm trying to teach myself C++ at the moment, after years of C# and other managed languages. The class in question is a Level in a game, and the idea is to ...
12
votes
0answers
105 views

Tiny Lua library to get char pointer from string

Background I'm using Lua with luaglut to do some OpenGL stuff. The luaglut API is almost identical to the gl/glut C APIs. Sometimes, gl functions want a pointer to some data, for example: ...
0
votes
1answer
55 views

Possible memory issue in linked list program [closed]

I am trying to write a program which will count the occurrence of words in a paragraph. The logic I am following : I am using a linked list for the purpose. And I am searching sequentially - if new ...
9
votes
3answers
523 views

Checking for palindromes using dynamic memory allocation

This is a homework assignment, but it's already done and it's not for a grade; it's meant as a refresher for the rest of the course. I've never done anything with dynamic memory allocation in C ...
6
votes
1answer
60 views

File validator configured using XML

I am making an application to check for any files that does not follow a specific pattern defined in a XML file. The application works well, but the source code is not the greatest, and memory ...
0
votes
1answer
122 views

Decrease file size of encrypted file

I am making a Cryptography application and I noticed that the encrypted file is approximately 2 times bigger because I am encoding the files in base64. Are there any file encodings that take less ...
-1
votes
1answer
53 views

Game LevelManager Memory Leak? [closed]

I have a level manager for my game I'm working on, and it's supposed to unload the previous level, and then load the next level. However, when I test it (though I'm not sure I'm testing it right) the ...
5
votes
2answers
171 views

Singleton typed memory manager

For my resources management, I wanted the objects allocated on the heap to be in a contiguous block of memory. Obviously, each data type then has to have their own chunk of memory. I could have used a ...
7
votes
3answers
383 views

Hierarchical k-ary tree in C without relying on RAM

I created a k-ary tree in C to be used as an easy and efficient way to organize "UML-like" data in embedded devices. The left node is at the lower logical level (a child) while the right node is at ...
6
votes
1answer
134 views

Possible memory leak in a for loop macro

I was reading about similar problems to the one I am having, and my guess is that I am having a 'memory leak'. I'm not sure exactly what that means, or how to correct it. Could you take a look at my ...
5
votes
3answers
108 views

CSV demographics analyzer seems to waste memory/move slowly

I'm much more fluent in JS, but I needed to sort a lot of dates, ages, genders, etc. from a tab-delimited text file so I wrote this. Could I get some tips on how to make this more efficient and more ...
1
vote
1answer
222 views

Image upload and thumbnail creation script using PHP GD

Ignoring my shocking use of the mysql_* extension (and any associated issues), could you take a look at my script that uploads an image, adds it to a database, ...
4
votes
1answer
133 views

Maintaining a car collection list in a multithreaded application

I have a multithreaded application for web scraping from an automobile website. While performing web scraping, there are many links that gives the same result, so I have to check for data redundancy. ...
2
votes
0answers
58 views

Code elimination once it is conditionally dead [closed]

A situation when programming code becomes dead dynamically or conditionally, such as here in this scenario. I don't want my code to be failure victim of branch prediction. ...
4
votes
1answer
190 views

Permutations program in Python

This code asks for letters and a number of letters per word and generates all possible permutations. Then compares those permutations with an English dictionary and creates a list with all the words ...
8
votes
3answers
348 views

Travelling Salesman in Qt

I am writing a recursive function based on the Travelling Salesman Problem. Is this a correct way of doing things, or am I creating memory leaks? Prerequisites are: a two dimensional matrix ...
6
votes
2answers
400 views

Stack challenge - improving memory consumption

I am working on this problem: Stacks Imagine, that you are employed by a software development company. You work now on the famous "D++ project", which is devoted to the creation of a new ...
5
votes
3answers
215 views

Program falls over with larger input files

I have been translating a solution from C# into VB.Net, because I know more VB and wanted to understand it better. I have a version up and running that replicates the C# performance with small input ...
2
votes
2answers
262 views

Counting occurrences of Char8s in a file

To learn some Data.Map and Control.Monad.State, I have written the following code, which should count the occurrences of ...
2
votes
0answers
135 views

Possible memory leak with WPF Custom Control?

I might have a potential memory leak with my custom control. Do I actually have one? ...
3
votes
1answer
107 views

Checking for memory leaks in data structures

I'm looking for a code review for my JavaScript code that checks if there is any memory leaks in data structures. Please include constructive criticism, as well as details on what I can do to make ...
10
votes
4answers
181 views

Bare-bones string library

After years of criticizing others, I've finally found the time and worked up the courage to polish up one of my bits of code and solicit criticisms of my own. This is a simple dynamic-string library ...
4
votes
1answer
57 views

Allocating memory and releasing the same [closed]

I was going through a code snippet... ...
3
votes
2answers
337 views

Java Manual-Reference-Counting

I have a Java game development framework. Certain classes, such as Texture, need to be disposed as soon as you don't need them - we cannot depend on the Garbage ...
3
votes
1answer
142 views

Auto-recycling C++11 polymorphic smart pointers

I've recently read an interesting blog post by Philipp Zschoche: it explains how it's possible to avoid unnecessary allocations/deallocations by keeping track of previously allocated memory in a ...
3
votes
2answers
326 views

Slow data-processing and inefficient memory usage in .NET containers

I am writing a text classifier and in order to do so I need TF/IDF values per every word of my signle text. Then I need to use the cosine similarity: \$similarity = cos(\theta) = \dfrac{A \cdot ...
2
votes
2answers
158 views

Fastest / most efficient random bit indexing in Python

Using Python/Cython, I am trying to construct an efficient way to index boolean values. I have been trying to use the bitarray and/or bitstring packages to construct a fast, non memory intensive way ...
5
votes
1answer
1k views

Hackerrank Gem Stones

I am working on some problems on Hackerrank. John has discovered various rocks. Each rock is composed of various elements, and each element is represented by a lowercase Latin letter from 'a' to ...