Intel® Integrated Performance Primitives
Deliberate problems developing high-performance vision, signal, security, and storage applications.

JPEG-IJL memory leak

daveabrams
Beginner
546 Views
Hi,
I've been usingijl11.dll for years with no problems.
I'm repeatedly doing JPEG decompress in a loop.
When I compile the JPEG-IJL project to create
ijl20.dll using IPP40, and use the new ijl.h
the resulting code gradually leaks memory
in my app.
I'm using an eval version of Win IPP 4.0.
Any ideas?
0 Kudos
8 Replies
Intel_C_Intel
Employee
546 Views
Hi,
could you please provide more details, what processor do you use? May be we can provide simple test case?
Regards,
Vladimir
0 Kudos
daveabrams
Beginner
546 Views

I submitted it to Primier support.

I'm using 1Ghz PIII mobile, Win2000, 1G RAM, Compaq Evo

Have you ever tested repeatedly decompressing JPEG's using ijl20.dll ?

0 Kudos
Intel_C_Intel
Employee
546 Views

Hi,

of course, we tested IJL-IPP sample, and we found no problem with it. Could you reproduce this problem with JPGView sample, which comes with IJL?

Regards,
Vladimir

0 Kudos
Kelvin
Beginner
546 Views
Hi,

I got similar problem. I'm using
JPGViewjpegcodecdecoder.cpp

in Xeon winXP. There is about 1K memory leak
each time I invoke decoder decode function.
If I replace it by JPEG sample come with
IPP 4.0 (but still use IPP 4.1 library)
there is no such problem.

Another problem is in
jpegcodecencode.cpp, in IPP 4.0 jpeg
sample we can get the length of destination
after encode. But there is no such information
return. How can we know the size of jpeg encode ?

Thanks.

- Kelvin

http://graphics.usc.edu/~tatchung/
0 Kudos
Vladimir_Dudnik
Employee
546 Views
Hi,
you are right, we found several mistakes in JPEGView sample's source code.
to correct memory leakage in decoder you need to remove one line in dechtbl.cpp file:
JERRCODE CJPEGDecoderHuffmanTable::Destroy(void)
{
m_id = 0;
m_hclass = 0;
m_table = 0; // REMOVE this line

ippsZero_8u(m_bits,sizeof(m_bits));
ippsZero_8u(m_vals,sizeof(m_vals));

if(0 != m_table) {
ippFree(m_table);
m_table = 0;
}

m_bEmpty = 1;

return JPEG_OK;
} // CJPEGDecoderHuffmanTable::Destroy()
The similar mistake is also in enchtbl.cpp file.
Regarding size of encoded JPEG you can use code like this:
BOOL CJPGViewDoc::SaveAsJPEG(LPCTSTR lpszPathName)
{
.....;
JPEGSize = encoder.m_dst.currPos; //add this code
jpeg.Write(pJPEG,JPEGSize);
......;
}
Regards,
Vladimir
0 Kudos
Kelvin
Beginner
546 Views
Hi Vladimir,

Thanks for your help. It is fast.
It works now without memory leak. :-)

Another usage we're trying is reuse
single instance of decoder i.e.

CJPEGDecoder decoder;

while (true) {
// get image data here
decoder.ReadHeader(..)
decoder.SetDestination(..)
decoder.ReadData(..)
decoder.Reset();
}

We find there is memory leak if I do this.
is the function Reset() is design to do this ?
Cause we would like, if possible, not to
reallocate and ippFree() stuff in each frame.


Another question is how is the performance of
jpeg decode for 64-bit Xeon compare to 32 bit
Xeon ? Is it double ?
We haven't bought 64-bit xeon yet until we can verify the performance enchacement.

Thanks.

- Kelvin
0 Kudos
Vladimir_Dudnik
Employee
546 Views
Kelvin,
yes, we are in preparation of the next version of IPP right now. This version will include modified JPEG sample. Modification will be related to minimization of memory allocation inside, especially for Motion JPEG case, where all frames have the same size, so internal buffers can be reused.
To free decoder internal buffersmethod Clean() should be used.
Actually, you can estimate performance of IPP on any supported platform even without that platforms. Just take a look into performance data we distribute with IPP, you can find it in your IPPia32_itanium oolsperfsysdata folder. There is results of IPP performance tests (for JPEG it includes JPEG codec performance as well as performance of separate IPP functions).
Regards,
Vladimir
0 Kudos
Kelvin
Beginner
546 Views
Vladimir,

Actually I try .Clean() also in the loop
but it doesn't work. Never mind we'll wait
for the next jpeg samples which optimized
for Motion jpeg.

Thanks for your support.

- Kelvin
0 Kudos
Reply