Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: C++ Memory allocation versus memory PC  (Read 6595 times)

0 Members and 1 Guest are viewing this topic.

djm_jm

  • Newbie
  • *
  • Posts: 23
    • View Profile
C++ Memory allocation versus memory PC
« 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.

Arcade

  • Full Member
  • ***
  • Posts: 230
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #1 on: February 22, 2017, 04:15:59 pm »
What is the actual error you are getting?

djm_jm

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #2 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.

« Last Edit: February 22, 2017, 04:40:09 pm by djm_jm »

JayhawkZombie

  • Jr. Member
  • **
  • Posts: 76
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #3 on: February 22, 2017, 04:38:43 pm »
Could you post the code that is giving you the problem?

djm_jm

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #4 on: February 22, 2017, 04:45:35 pm »
Could you post the code that is giving you the problem?

it's attached.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: C++ Memory allocation versus memory PC
« Reply #5 on: February 22, 2017, 05:11:32 pm »
Where are you handling events?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: C++ Memory allocation versus memory PC
« Reply #6 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"
 
I would like a spanish/latin community...
Problems building for Android? Look here

djm_jm

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #7 on: February 22, 2017, 05:23:07 pm »
Ok, here in this attachement is all code. The events happen in the main.

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: C++ Memory allocation versus memory PC
« Reply #8 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?
I would like a spanish/latin community...
Problems building for Android? Look here

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: C++ Memory allocation versus memory PC
« Reply #9 on: February 22, 2017, 06:06:01 pm »
So when you run it through your debugger, what's the call stack?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

djm_jm

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #10 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.


djm_jm

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #11 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

djm_jm

  • Newbie
  • *
  • Posts: 23
    • View Profile
Re: C++ Memory allocation versus memory PC
« Reply #12 on: February 23, 2017, 04:09:27 pm »
Anybody has any Idea about this problem?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11016
    • View Profile
    • development blog
    • Email
Re: C++ Memory allocation versus memory PC
« Reply #13 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?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/