I think I have found the problem, but it really has nothing to do with memory releases.
I commented all the code I had, leaving only vertex shader creation and deletion. And this creation of the shader caused the leaks (I was releasing it properly). So again I took a look into this shader. Here it is:
uniform float4x4 worldTransform;uniform float4x4 viewProjTransform;struct VS_INPUT{ float4 position: POSITION; float3 normal: NORMAL; float2 texCoord: TEXCOORD0;};struct VS_OUTPUT{ float4 position: POSITION; float3 normal: TEXCOORD0; float2 texCoord: TEXCOORD1; float3 worldPosition: TEXCOORD2;};VS_OUTPUT main(VS_INPUT input){ VS_OUTPUT output; // world-space float4 position = mul(input.position, worldTransform); float3 normal = mul(input.normal, (float3x3)worldTransform); output.position = mul(position, viewProjTransform); output.normal = normal; output.texCoord = input.texCoord; output.worldPosition = position; return output;}
Note what I'm doing in the last output assignment. I assign float4 to float3 without casting. If I do the casting, or simply change worldPosition to float4 or "float4 position" to "float3 position", the leaks don't show.
So can this really cause a leak? If I were to guess then I'd say that DirectX makes a leak during shader parsing. I'm almost sure of that because when I load my shader from cache (with D3DXAssembleShader and using a constant table generated from the previous program running) the leaks don't appear. I'd dare to say it is a bug (yet very slight) of DirectX (I'm using v. June 2010) shader parsing :)