SFML community forums

Help => General => Topic started by: djm_jm on February 22, 2017, 03:38:21 pm

Title: C++ Memory allocation versus memory PC
Post by: djm_jm on February 22, 2017, 03:38:21 pm
Good morning all.

I have one problem here about my current project. It happens errors when I allocate one small number of object in the main( mean create a object\variable ). This class I have created  and it has some sfml text's vector structures (20 each, exactly). When I remove some those objects, the program works fine.

My doubt is the following. My PC has 6GBs ram and the program running spend around 32Mbs. I don't believe that my PC no have enough memory to allocate the program.

This can seems a noob doubt, but I will be glad if anybody can help me with it.
Title: Re: C++ Memory allocation versus memory PC
Post by: Arcade on February 22, 2017, 04:15:59 pm
What is the actual error you are getting?
Title: Re: C++ Memory allocation versus memory PC
Post by: djm_jm on February 22, 2017, 04:36:34 pm
What is the actual error you are getting?

I use windows, then, the error appears as "program has stopped working". See the attached file. If I remove some few value of the vector, the program run fine, so because this I think the problem is allocation.

Title: Re: C++ Memory allocation versus memory PC
Post by: JayhawkZombie on February 22, 2017, 04:38:43 pm
Could you post the code that is giving you the problem?
Title: Re: C++ Memory allocation versus memory PC
Post by: djm_jm on February 22, 2017, 04:45:35 pm
Could you post the code that is giving you the problem?

it's attached.
Title: Re: C++ Memory allocation versus memory PC
Post by: eXpl0it3r on February 22, 2017, 05:11:32 pm
Where are you handling events?
Title: Re: C++ Memory allocation versus memory PC
Post by: DarkRoku12 on February 22, 2017, 05:18:44 pm
The code you just shown does not have the entire code. Only a part of it (a class to be more specific)

where are?
#include "BUTTON.h"
#include "LAYER.h"
#include "TEXTING.h"
 
Title: Re: C++ Memory allocation versus memory PC
Post by: djm_jm on February 22, 2017, 05:23:07 pm
Ok, here in this attachement is all code. The events happen in the main.
Title: Re: C++ Memory allocation versus memory PC
Post by: DarkRoku12 on February 22, 2017, 05:39:07 pm
Ok, here in this attachement is all code. The events happen in the main.

Thanks for attatching, i'll try to test your code, but let me ask a question: Do you come from a Java or C# environment?
Title: Re: C++ Memory allocation versus memory PC
Post by: eXpl0it3r on February 22, 2017, 06:06:01 pm
So when you run it through your debugger, what's the call stack?
Title: Re: C++ Memory allocation versus memory PC
Post by: djm_jm on February 22, 2017, 07:04:22 pm
So when you run it through your debugger, what's the call stack?

Again, the info is in attached.

Title: Re: C++ Memory allocation versus memory PC
Post by: djm_jm on February 22, 2017, 07:15:35 pm
Ok, here in this attachement is all code. The events happen in the main.

Thanks for attatching, i'll try to test your code, but let me ask a question: Do you come from a Java or C# environment?

My history is the that:

I have learned programming in c language, I had made only small procedure programs (no interface, only terminal), I don't had much knowledge about OOP. Because these causes I wanted learn about c++. After sometime, I beggin search about apis to make GUIs, games and things of type. And now I am here, with some begginer doubts.  ;D
Title: Re: C++ Memory allocation versus memory PC
Post by: djm_jm on February 23, 2017, 04:09:27 pm
Anybody has any Idea about this problem?
Title: Re: C++ Memory allocation versus memory PC
Post by: eXpl0it3r on February 23, 2017, 04:45:51 pm
Since it crashes right after the main function (line 6), you're either doing some bad global stuff in the headers, or you've a faulty setup. Does it also crash if you run it by double clicking it in explorer?
Try to narrow down the problem, by reducing your code until you're left with a minimal code base that reproduces that issue. Or start with a fresh project and rebuild your code until you run into the same issue again.

Do you run any "odd" applications in the background? What's your AV software?