如题,在3.6和3.8.1版本都试过 问题一样
auto glprogram = GLProgram::createWithFilenames(“vert.vsh”, “frag.fsh”);
auto glprogramstate = GLProgramState::getOrCreateWithGLProgram(glprogram);
_sprite->setGLProgramState(glprogramstate);
auto textrue1 = Director::getInstance()->getTextureCache()->addImage("***.jpg");
glprogramstate->setUniformTexture(“u_texture1”, textrue1);
auto textrue2 = Director::getInstance()->getTextureCache()->addImage("***.png");
glprogramstate->setUniformTexture(“u_texture2”, textrue2);
Texture2D::TexParams tRepeatParams;
tRepeatParams.magFilter = GL_LINEAR;
tRepeatParams.minFilter = GL_LINEAR;
tRepeatParams.wrapS = GL_REPEAT;
tRepeatParams.wrapT = GL_REPEAT;
textrue2->setTexParameters(tRepeatParams);
long offset = 0;
auto mesh = _sprite->getMesh();
auto attributeCount = mesh->getMeshVertexAttribCount();
for (auto k = 0; k < attributeCount; k++) {
auto meshattribute = mesh->getMeshVertexAttribute(k);
int vertexSizeInBytes = mesh->getVertexSizeInBytes();
glprogramstate->setVertexAttribPointer(s_attributeNames,
meshattribute.size,
meshattribute.type,
GL_FALSE,
vertexSizeInBytes,
(GLvoid*)offset);
offset += meshattribute.attribSizeBytes;
}
如上代码中_sprite是一个3D模型,此段代码就是给模型添加自定义shader,每新建一次这个shader内存就涨一次,模型被销毁之后内存依然没有消减,反复创建模型并给赋上shader,过会销毁模型。。。如此反复。。。
内存会一直持续上涨。
如果不添加shader,内存不会变化。。。
谁来解决下啊,困扰已久