Questions tagged [memory-management]

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.

Filter by
Sorted by
Tagged with
5
votes
2answers
895 views

Human (imperfect) array (card) shuffle written in C

I've got this humanoid_shuffle I wrote in Python. I've been wanting to learn C so as an exercise I ported it to C. As this is my first venture into C and even the ...
3
votes
1answer
900 views

Memory leak in a scraper [closed]

This is a scraper written in CoffeeScript for NodeJS. It is run in an interval (set to 5 seconds here to dramtically show the leak). Somewhere this code leaks memory. I already tried nulling a few ...
6
votes
1answer
656 views

Memory issues with Find Strings Problem on InterviewStreet

Here is the code I wrote for the problem at http://www.interviewstreet.com/recruit/challenges/solve/view/4e1491425cf10/4efa210eb70ac where we need to to print the substring at a particular index from ...
6
votes
1answer
287 views

Is this a good algorithm for 2D collision, or will it allocate too much memory?

I have a Rectangle class, of which I have 5-6 vectors for each instance. The main vectors are the center and color of the object, while the secondary vectors represent more or less the north, south, ...
4
votes
3answers
750 views

Simple, lightweight deterministic “garbage collection”

I am toying with a simple class to inherit from to manage my dynamic resources. I am fairly new to C++, so my "implementation" might be suboptimal. Suggestions how to improve functionality are welcome....
3
votes
1answer
179 views

Am I managing my memory correctly?

I read that if an object is made using the init it must be released, but if it's something like this ...
6
votes
3answers
832 views

App for allowing the user to type in chemistry formulas using a custom keyboard

Essentially, I am making an app that allows the user to type in chemistry formulas using a custom keyboard. The keyboard will have several keys, for example, "Na", "H", and "O". Pressing them in ...
8
votes
1answer
4k views

Super simple templated memory pool in C++

I have a small program where I have a background thread that plays sound, so it needs to run really fast, but it also needs to do a small amount of memory management. I didn't want to use normal new ...
2
votes
1answer
329 views

Runge-Kutta 2nd order of differential equations

Could I improve this somehow (not numerically, just C-wise)? Do I need to allocate the array since I am returning it and not just using it inside the function? ...
11
votes
3answers
1k views

Reusing strings read from I/O

I am working on an application that reads lots of data from the network and puts it in a grid. I noticed that I could save some memory by reusing existing strings instead of always using the new ...
4
votes
2answers
199 views

Array initialization from text string

I have a block of text where several arrays are printed out, with a name and values: VAL1=10 20 30 40 50 VAL2=4 8 15 16 23 42 I have a function that looks for the value name, and sets an ...
7
votes
1answer
716 views

Double-Ended Queue - Have I over-engineered it again?

I'm working on an implementation of the Double-Ended Queue as a Doubly-Linked List (for personal enrichment), and I was wondering if anyone minded taking a look at my Constructor/Destructor and Empty ...
3
votes
1answer
331 views

My program spikes from 100,000K mem to 1,000,000K mem in a matter of minutes in my program in VB.net [closed]

I've created a program that uses System.Graphics to render a simple (small) 2D scene to the screen. The problem is, for some reason, it starts to quickly ...
1
vote
2answers
324 views

NSAutoreleasePool with Json Data

Just need to know if I'm doing something wrong in this code. my app seem work fast now with this code. I just want to if i really understant that ...
5
votes
1answer
214 views

Overloading the new operator

This may be a naive question, but what are the dangers of the following code (allocate more memory in the new operator for the info struct)? ...
3
votes
1answer
1k views

Does this I/O operation caused a memory leak [closed]

My colleague did some code Optimise work. Code below is from a public method of a public class (NOT STATIC CLASS OR METHOD) code before: ...
3
votes
1answer
1k views

Memory leaks in lottery simulator

I'm primarily a C++/Java programmer, but I've recently started using Python at work and decided to write a Lottery Simulator at home. I wrote it to test out different combinations of lottery numbers ...
8
votes
2answers
2k views

BitTorrent peer protocol messages

I'm writing a BitTorrent client. Part of the protocol is an exchange of length-prefixed messages between peers. The forms of these messages are described in the official specification and also in the ...
1
vote
1answer
599 views

Memory Question

Can this part of a view controller subclass be checked for memory leaks. I am not that good at finding leaks. I need this class to be able to be loaded many time over without it crashing due to memory ...
3
votes
0answers
1k views

Integrating SFML and Box2D lib, and a Mass Production Shape Factory

I've just written two new headers: one that integrates Box2D and SFML by a class called BodyRep which creates/ is a graphic representation of any body, and one that ...
8
votes
1answer
493 views

Use of external memory or a custom allocator

I'm creating a class which uses a custom buffer. I want to offer the possibility to pass an external memory address (for higher interoperability between languages) or (for convenience) to specify a ...
4
votes
2answers
3k views

Allocating memory for a matrix with a single malloc

For an interview, I was asked to write code allocate memory for a rows*cols matrix, using a single malloc(). I want your comments about this code that I wrote: <...
2
votes
2answers
2k views

Subclassing UIButton

I need to subclass UIButton, however the design of UIButton makes this really painful. This is because to create a button you ...