473,394 Members | 1,674 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Huge problem with memory usage

Hi!

I am making a game in C++ using SDL.
But I have this big problem.
It just takes more and more memory as it runs.
It can be downloaded at:
http://www.caturn.dk/newgame.html
Does anyone have the slightest idea what the problem could be?
It does'nt declare any new variables while it runs (only in the start)
but changes the ones already declared.

Please help me. It's driving me crazy.
Christian

P.S. Sorry for my bad English
Jul 22 '05 #1
5 1299
Christian Br?nnum-Hansen wrote:
I am making a game in C++ using SDL.
But I have this big problem.
It just takes more and more memory as it runs.
It can be downloaded at:
http://www.caturn.dk/newgame.html
Does anyone have the slightest idea what the problem could be?
It does'nt declare any new variables while it runs (only in the start)
but changes the ones already declared.


Rewrite your project from scratch, using "test driven development". Then you
can instrument each test to detect leaks, and the test will tell you what
subset of code's doing it.

If you simply must persist with the current code, cut it in half and see
which half leaks. Keep going until you have a very small code sample that
leaks. If you still can't see the leak, post that snip here.

Alternately, look up one of the (off-topic) heapwalk() functions, put it
into a function called "detectLeak()", and call that function everywhere.
Put a breakpoint in it, and see which code first becomes leaky.

Alternately, get a leak detector such as (IIRC) "electric fence", or
similar.

But asking all of us to read all of your code is very inefficient, unless
you - who are more familiar with the code - does some preparation first.

--
Phlip
http://www.xpsd.org/cgi-bin/wiki?Tes...UserInterfaces
Jul 22 '05 #2
Phlip wrote:

Alternately, look up one of the (off-topic) heapwalk() functions, put it
into a function called "detectLeak()", and call that function everywhere.
Put a breakpoint in it, and see which code first becomes leaky.


And start out with really, really simple test cases. Performance
typically drops through the floor when you do this, and it's easy to
fool yourself into thinking the application has crashed when it has
merely become glacially slow. <g>

--

Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
Jul 22 '05 #3
Christian Br?nnum-Hansen wrote:
Hi!

I am making a game in C++ using SDL.
But I have this big problem.
It just takes more and more memory as it runs.
It can be downloaded at:
http://www.caturn.dk/newgame.html
Does anyone have the slightest idea what the problem could be?
It does'nt declare any new variables while it runs (only in the start)
but changes the ones already declared.


Even if one would like to help you, it is impossible without the source
code.

Christoph
Jul 22 '05 #4
I will probably do the thing about cutting the code in half as it
should not be any problem the way I've written it.

But maybe there is a function which tells how much RAM is being used?
Then I could put it everywhere in the code and see where the amount of
used RAM increases.
Jul 22 '05 #5
"Christian Br?nnum-Hansen" <br************@mail.dk> wrote in message
news:a7*************************@posting.google.co m...
I will probably do the thing about cutting the code in half as it
should not be any problem the way I've written it.

But maybe there is a function which tells how much RAM is being used?
Then I could put it everywhere in the code and see where the amount of
used RAM increases.


There is no standard function for this, but maybe that platform you are
using has one. Alternatively you might consider using a leak detection tool
to figure out what part of your code is leaking resources.

--
Peter van Merkerk
peter.van.merkerk(at)dse.nl
Jul 22 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Hans Georg Krauthaeuser | last post by:
Dear all, I have a long running application (electromagnetic compatibility measurements in mode-stirred chambers over GPIB) that use pickle (cPickle) to autosave a class instance with all the...
53
by: john67 | last post by:
The company I work for is about to embark on developing a commercial application that will cost us tens-of-millions to develop. When all is said and done it will have thousands of business...
5
by: Justice | last post by:
Currently I'm doing some experimenting with the XMLHTTP object in Javascript. Now, the XMLHttp object is asynchronous (at least in this case), and the following code causes a significant memory...
3
by: Ian Taite | last post by:
Hello, I'm exploring why one of my C# .NET apps has "high" memory usage, and whether I can reduce the memory usage. I have an app that wakes up and processes text files into a database...
7
by: Vasil Buraliev | last post by:
Hallo. I started a solution in VS.NET with template for C# windwos application. The solution has several projects: -Artifacts -BusinessRules -Client -ErrorLog -Standardization .... ... ..
6
by: Daniel Walzenbach | last post by:
Hi, I have a web application which sometimes throws an “out of memory” exception. To get an idea what happens I traced some values using performance monitor and got the following values (for...
8
by: Sullivan WxPyQtKinter | last post by:
a relation database has admiring search efficiency when the database is very big (several thousands or tens of thousands of records). But my current project is based on XML, for its tree-like data...
13
by: vd12005 | last post by:
Hello, i would like to sort(ed) and reverse(d) the result of many huge dictionaries (a single dictionary will contain ~ 150000 entries). Keys are words, values are count (integer). i'm...
12
by: Tony | last post by:
Hi expert, I installed DB2 v8.2 server on Solaris 9 box. When I connect to DB2 using control centre or other applications(except command line), around 12 db2sysc processes pop up and each one...
3
by: Mohamed Yousef | last post by:
Thanks all , but there is still something i forget to state -sorry - all communication will be via Http with a server so data is received via Http so local network solutions won't work the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.