All Forums
 Microsoft Windows CE
 General CE
 BitsyXb sleep/wake memory leak
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Author Topic  

erasmussen

15 Posts

Posted - 29 Mar 2010 :  12:55:14  Show Profile  Email Poster
I have been trying to find memory leaks in our application. We typically lose about 4kBytes per hour. We wake up, collect data, process it, output results and goto sleep 6x per hour. As a test I ran over the weekend without the sleep - and the memory leak was 100%gone.

Has anybody experienced a similiar leak relating to sleep mode? I am trying to establish if it is something wrong with what we are doing in restoring the system, or if it is an OS leak/BitsyXB leak.

Any help is appreciated.

akidder

1519 Posts

Posted - 29 Mar 2010 :  13:12:12  Show Profile  Email Poster
We wil be glad to help you figure out where the leak lies.

Here are a few questions for consideration:
- Can you increase the rate of sleep cyles for test purposes?
- Does your application use the CE Compact Framework? (it performs garbage collection on its own schedule)
- Is this a new issue? If so, what changed?
- Does the system end up running out of memory if this memory consumption goes unchecked?

It will probably be easier to work in this project more directly, rather than on the forums. If you want, drop me or another on the support team (support.us@eurotech.com) a line to set up a time to talk.

Cheers, Drew
Go to Top of Page

ctacke

877 Posts

Posted - 29 Mar 2010 :  13:41:14  Show Profile  Email Poster
I'd say another question for consideration is:
- Do you see the leak if you sleep/wake cycle the device without the app running?

This will help narrow down the "where".
Go to Top of Page

erasmussen

15 Posts

Posted - 31 Mar 2010 :  17:32:08  Show Profile  Email Poster
I have written a test application to help isolate the source of the problem::
=========================================
#include "stdafx.h"
#include "watchdog.h"
extern "C" __declspec(dllimport) void GwesPowerOffSystem();

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow)
{
SYSTEMTIME time;
double * eatMems[100];
char * charPtr = NULL;
int lastTime=0;
int i = 0;

// eat memory up so there is a smaller pool to play with
do
{
eatMems[i] = new double[100000];
} while (eatMems[i++] != NULL);

while (1)
{
if (charPtr != NULL)
{
delete [] charPtr;
charPtr = NULL;
}

// allocate a new array, mixing up sizes to represent real-world conditions better
int memAmt = (int)(((double)rand())/((double)RAND_MAX + 1.0))* 100000;
charPtr = new char[150000 + memAmt];

// attempt to write to buffer
strcpy(charPtr, "FILLER DATA");

MEMORYSTATUS memInfo;
memInfo.dwLength = sizeof(memInfo);
GlobalMemoryStatus(&memInfo);
GetLocalTime(&time);
RETAILMSG(1, (TEXT("GMS:%02d/%02d/%d-%2d:%02d:%02d %d,%d,%d,%d,%d,%d\r\n"), time.wMonth, time.wDay, time.wYear, time.wHour, time.wMinute, time.wSecond, memInfo.dwTotalPhys, memInfo.dwAvailPhys, memInfo.dwTotalVirtual, memInfo.dwAvailVirtual, memInfo.dwTotalPageFile, memInfo.dwAvailPageFile));

int thisTime = time.wHour*60 + time.wMinute;

// check for 3 minutes going by as a way to exit app to avoid turning system into a brick
if ( (lastTime > 0) && ((thisTime - lastTime) > 1) )
{
exit(0);
}
else
{
lastTime = thisTime;
}

RETAILMSG(TRUE,(L"Entering Suspend..."));
GwesPowerOffSystem();// suspend
RETAILMSG(TRUE,(L"...Exiting Suspend\r\n"));
}

return 0;
}

=========================================
I run this on the BitsyXb and use a Function generator to wake up the BitsyXb every 5 seconds. After about 24 hours the unit crashes. Looking at the dump of available memory I see:

Memory Leak

To me this conclusivly indicates that there is a memory leak in the sleep/wake cycling. This leak does not appear to be there when we do not wake/sleep. On our systems we sleep/wake every 10 minutes rather than 5 seconds so the timescale of the crash is much longer. In reality I am seeing the same memory profile and a crash after 88 days of sleep/wake every 10 minutes.

If Eurotech can confirm this issue independantly it would be greatly appreciated. We would also like to know if there is any possibilty for a fix or if we need to re-engineer our use so that the system resets periodically to avoid the crash.

Edited by - erasmussen on 31 Mar 2010 17:33:42
Go to Top of Page

akidder

1519 Posts

Posted - 31 Mar 2010 :  18:32:07  Show Profile  Email Poster
Thanks for the details. It looks like whatever process is consuming the memory is also releasing it when memory gets low. It just doesn't do it the last time, which causes the failure.

Could you let us know which BitsyXb build you are using? I'm sure you've seen that 5.00.51 did resolve one memory leak that we found.
Go to Top of Page

erasmussen

15 Posts

Posted - 31 Mar 2010 :  18:39:08  Show Profile  Email Poster
We are using:

Windows CE Ver.(5.00.49 BitsyXb_Core)

The 5.00.51 looks to be Pro Hive, is there a Core version available?
Go to Top of Page

grenierm

133 Posts

Posted - 02 Apr 2010 :  15:00:05  Show Profile  Email Poster
Thanks for the CE Image version information.

After conferring with our SW Development Team we are going to conduct an investigation on our end to attempt to reproduce this issue.

Feel free to check-in with us directly at support.us@eurotech.com for a status update periodically.
Go to Top of Page

erasmussen

15 Posts

Posted - 14 Apr 2010 :  15:56:12  Show Profile  Email Poster
As a comparison, here is the memory analysis I did running our software. It is striking how the two charts look alike:

Memory Leak
Go to Top of Page

erasmussen

15 Posts

Posted - 15 Apr 2010 :  11:31:58  Show Profile  Email Poster
Can you say if there are any plans to release a 5.00.51 Core version?
Go to Top of Page
  Topic  
 Forum Locked
 Send Topic to a Friend
 Printer Friendly
Jump To:
Eurotech Support Forums © Eurotech Inc. Go To Top Of Page
This page was generated in 0.05 seconds. Snitz Forums 2000