I suspected a memory leak in my game so I let it run for about an hour and I finally got a crash message ...
If anyone can provide an explanation for this error that would be awesome.
std:bad_alloc
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Party member
- Posts: 559
- Joined: Wed Oct 05, 2016 11:53 am
Re: std:bad_alloc
Can you show code?
- BruceTheGoose
- Citizen
- Posts: 76
- Joined: Sat Sep 20, 2014 2:54 pm
Re: std:bad_alloc
Here are the relevant code snippets:
I have a scroll frame object with a function that gets all of the visible objects :
Code: Select all
function Scroll:getVisibleObjects()
local visible = {}
for i = 1, #self.content.objects do
if(self:checkCollision(self.content.objects[i])) then
visible[#visible + 1] = i
end
end
return visible
end
Code: Select all
function Scroll:update(dt, scrolling)
self:handleScrollbar()
if(self.content.height > self.height) then
self:handleScrolling(dt)
self.touched = self:getTouch()
if(self.touched) then
self:handleTouch(dt, scrolling)
else
self:handleRelease(dt)
end
end
self.visible = self:getVisibleObjects()
self.content:update(dt, self.visible)
end
Code: Select all
function Button:draw()
if(self.visible) then
lg.setColor(0, 0, 0, self.shadowIntensity)
lg.draw(Loader.gfx["boxshadow"], self.x + self.shadowOffsetX, self.y + self.shadowOffsetY, 0, self.shadowScaleX, self.shadowScaleY)
lg.setColor(self.colorHover[1], self.colorHover[2], self.colorHover[3], self.alpha)
lg.rectangle("fill", self.x, self.y + self.height * 0.55, self.width, self.height * 0.5, self.roundness, self.roundness) -- Line 97
......
"I don't know."
-
- Party member
- Posts: 559
- Joined: Wed Oct 05, 2016 11:53 am
Re: std:bad_alloc
Can't really spot anything that could be at fault in those snippets, because it doesn't really show the internal workings of your code. However, what does do? Is that the line 97 the game errors on?
Code: Select all
Loader.gfx["boxshadow"]
- slime
- Solid Snayke
- Posts: 3166
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: std:bad_alloc
std::bad_alloc is just a generic "out of memory" message – LÖVE's internal C++ code tries to allocate some memory but either the program has already run out of memory by that point, or you're making it allocate a massive amount of memory due to the arguments you pass in to the function that's outputting that error.
It's probably going to be really hard to see where your memory leak is coming from without a .love file.
It's probably going to be really hard to see where your memory leak is coming from without a .love file.
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 7 guests