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

Author Topic: Vertex array questions  (Read 1613 times)

0 Members and 1 Guest are viewing this topic.

netrick

  • Full Member
  • ***
  • Posts: 174
    • View Profile
Vertex array questions
« on: July 23, 2013, 09:31:39 am »
1) Is vertex array RAII object? I mean when I have a vector of vertex arrays and I call "vector.clear()", will there be any memory leaks?

2)

Quote
void sf::VertexArray::clear()

Clear the vertex array.

This function removes all the vertices from the array. It doesn't deallocate the corresponding memory, so that adding new vertices after clearing doesn't involve reallocating all the memory.

Does this mean that if I don't add new verticles after clearing vertex arrays there will be memory leak?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Vertex array questions
« Reply #1 on: July 23, 2013, 09:43:28 am »
Quote
1) Is vertex array RAII object? I mean when I have a vector of vertex arrays and I call "vector.clear()", will there be any memory leaks?
Yes, of course VertexArray releases its memory when it's destroyed. It would be a major mistake otherwise.

Quote
Does this mean that if I don't add new verticles after clearing vertex arrays there will be memory leak?
No. It just means that the memory will remain allocated until the vertex array is destroyed. VertexArray is just a std::vector, so if you know how a vector works then you know everything about VertexArray ;)
Laurent Gomila - SFML developer

 

anything