I have created cocos2d game. During testing i got some memory warnings, i solved all memory warnings in ipad3(New ipad) but i couldnt solve the below memory warning in ipad 1. Can you guys please help me....
1.
2012-08-01 22:19:16.399 Game[238:707] cocos2d: CCSpriteFrameCache: Trying to use file 'Animation.png' as texture
2012-08-01 22:19:16.662 Game[238:707] cocos2d: CCSpriteFrameCache: Trying to use file 'Ani.png' as texture
2012-08-01 22:19:16.681 Game[238:707] cocos2d: CCSpriteFrameCache: Trying to use file 'Faces.png' as texture
2012-08-01 22:19:16.753 Game[238:707] cocos2d: removeChildByTag: child not found!
2012-08-01 22:19:16.819 Game[238:707] Received memory warning.
2.
2012-08-01 22:23:11.573 Game[238:707] cocos2d: Received memory warning.
2012-08-01 22:23:11.573 Game[238:707] cocos2d: CCTextureCache: removing unused texture: img.jpg
2012-08-01 22:23:11.576 Game[238:707] cocos2d: CCTextureCache: removing unused texture: play.png
2012-08-01 22:23:11.582 Game[238:707] cocos2d: CCTextureCache: removing unused texture: img1.png
2012-08-01 22:23:11.585 Game[238:707] cocos2d: CCTextureCache: removing unused texture: youNeedToPopup.png
2012-08-01 22:23:11.590 Game[238:707] cocos2d: CCTextureCache: removing unused texture: popup.png
2012-08-01 22:23:11.599 Game[238:707] cocos2d: CCTextureCache: removing unused texture: conti.png
thanks
Memory warnings are completely normal. Indeed, this is the mechanism that allow iOS to retake back used memory that can be freed and continue working without crashing.
You can observe that in Instruments Allocation tools: memory is gradually filled up; then a memory warning is sent, and you will see memory quickly to be freed (up to a point). This is the sign of a healthy application.
What you should worry about is that, when a memory warning is sent out, memory is not recovered. But then your app would promptly be killed.
So, memory warnings + app not crashing is no worry at all.
Related
I've just implemented deferred rendering/shading for the first time and I was surprised to see the big perfomance gap between forward and deferred rendering.
When I run my application with forward rendering I get a pretty decent frame rate while running in Release mode
FORWARD RENDERING
However when I ran it with deferred rendering it gave me a rather surprising output
DEFERRED RENDERING
I'm well aware of that deferred rendering is NOT something you coat an application with to make it go "faster". I consider it to be a performance optimization technique that can be optimized in a numerous ways and I understand that the technique has a larger memory footprint than forward rendering.
However...
I've currently got ONE point light in the scene and one hundred cubes created with hardware instancing. The light is moving back and forth on the Z-axis casting light on the cubes.
The problem is that the light is very laggy when moving. It's so laggy that the application doesn't register the keyboard input. Honestly, I was not prepared for this and I assume that I'm doing something terrible bad in my implementation.
So far I've changed the texture format on the gbuffers from DXGI_FORMAT_R32G32B32A32_FLOAT to DXGI_FORMAT_R16G16B16A16_FLOAT jsut to see if it had any visual impact but it did not.
Any suggestions? Thank you!
SIDE NOTE
I'm using the Visual Studio Graphics Diagnostics for debugging my DirectX applications
Solved it!
I enabled the DirectX debug layer and I got a sea of D3D11 warnings
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 1 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets[AndUnorderedAccessViews]: Forcing PS shader resource slot 1 to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 2 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets[AndUnorderedAccessViews]: Forcing PS shader resource slot 2 to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets: Resource being set to OM RenderTarget slot 3 is still bound on input! [ STATE_SETTING WARNING #9: DEVICE_OMSETRENDERTARGETS_HAZARD]
D3D11 WARNING: ID3D11DeviceContext::OMSetRenderTargets[AndUnorderedAccessViews]: Forcing PS shader resource slot 3 to NULL. [ STATE_SETTING WARNING #7: DEVICE_PSSETSHADERRESOURCES_HAZARD]
So at the end of the render function i.e. after
mSwapChain->Present( 0, 0 );
I added
mDeviceContext->ClearState();
Just to reset the device context which sets all input/output resource slots to NULL as explained on MSDN
i created new project i added:
Size winSize = Director::getInstance()->getWinSize();
RenderTexture* pRenderTexture = RenderTexture::create(winSize.width, winSize.height, Texture2D::PixelFormat::BGRA8888);
and i keep getting this error:
cocos2d: Texture2D: Error uploading compressed texture level: 0 . glError: 0x0500
Assert failed: Could not attach texture to framebuffer
Assertion failed!
by the way the cpp-test RenderTexture example do work .
what im doing wrong here ?
Using:
cocos2d-x v3.3
win7 32bit
It means that BGRA8888 is not supported by your opengl. Use RGBA8888 if it suitable for you.
And you have typo:
RenderTexture* pRenderTexture; = RenderTexture::create
_____________________________^
I am getting crashes on iPhone 4s due to "memory pressure." My game is set up like this:
Main scene sprite sheet that always stays in memory.
Individual game scene levels load from individual textures (not sprite sheets).
When a level is done and we return to the main scene, I would like those cached game scene textures to get dumped. What ends up happening is that when you play through 3-4 levels, it crashes as it runs out of memory as it never releases this memory after a level. I don't want the level textures to be cached past the lifespan of the game scene. When returning to the main scene, it needs to release this memory.
I have tried removing all of the game scene children which does nothing to memory. I have tried looking for a specific way to clear just these textures I have loaded in this game scene from the cache.
Any suggestions?
Are you using cocos2d v2? You probably have memory leaks since unused textures are removed when necessary. Try profiling your app to see if you have leaks and where they are at.
You also can call these methods yourself at the appropriate time, although I doubt you'd have to:
[[CCTextureCache sharedTextureCache] removeUnusedTextures];
[[CCSpriteFrameCache sharedSpriteFrameCache] removeUnusedSpriteFrames];
But again what you describe sounds more like memory leaks. When your application receives a memory warning the cached data is purged. During this purge the remove unused textures method is called on the texture cache, among other things. If you have 3/4 levels of data still lurking around long after you've exited those scenes, that sounds like a memory leak.
I'm assuming this only happens after visiting multiple scenes and the problem just isn't that your 4th scene is simply trying to load more data than the device can handle.
You can remove specific textures calling:
In cocos2D-x v3.x :
Director::getInstance()->getTextureCache()->removeTextureForKey(ImageKeyName)
In cocos2D-x v2.x :
CCTextureCache::sharedTextureCache()->removeTextureForKey(ImageKeyName);
Where ImageKeyName is just the path of the image (the same you used to load the texture)
I have only a line to load particle.png, and the texture is embedded in it.
Sometimes the texture is seen and somethimes it does not appear.
I noticed I get a warning message:
cocos2d: Warning: File not found: particleTexture.png
My just code to load plist particle is this :
CCParticleSystemQuad emitter=[CCParticleSystemQuad particleWithFile:#"rain.plist"];
This is interesting:
Sometimes the texture is seen: sometimes it is not, and instead of the texture I see gradient balls.
i developed the game using levelHelper game is working fine but i am getting some error or some kind of warnings in the logs which are
2013-03-07 12:59:59.744 RobotRunner[3970:c07] cocos2d: ** WARNING
** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h
2013-03-07 12:59:59.745 RobotRunner[3970:c07] cocos2d: cocos2d v2.0.0
2013-03-07 12:59:59.745 RobotRunner[3970:c07] cocos2d: Using Director
Type:CCDirectorDisplayLink
2013-03-07 12:59:59.761 RobotRunner[3970:c07] Retina Display Not
supported
2013-03-07 12:59:59.765 RobotRunner[3970:c07] cocos2d: animation
started with frame interval: 60.00
2013-03-07 12:59:59.766 RobotRunner[3970:c07] cocos2d: surface size:
480x320
2013-03-07 12:59:59.767 RobotRunner[3970:c07] cocos2d: CCTexture2D:
Using RGB565 texture since image has no alpha
2013-03-07 13:00:00.905 RobotRunner[3970:c07] cocos2d:
CCSpriteBatchNode: resizing TextureAtlas capacity from [29] to [40].
can any body tell me how to solve these things and why it's showing
Only the first is a warning you can fix. It tells you how to do so.
The rest are just noise from cocos2d.
These are not warnings, these are informational\debug messages.