Search

Technical Discussion Group Forum

This forum is provided for user discussion. While Beacon EmbeddedWorks support staff and engineers participate, Beacon EmbeddedWorks does not guarantee the accuracy of all information within in the Technical Discussion Group (TDG).

The "Articles" forums provide brief Articles written by Beacon EmbeddedWorks engineers that address the most frequently asked technical questions.

To receive email notifications when updates are posted for a Beacon EmbeddedWorks product download, please subscribe to the TDG Forum of interest.

TDG Forum

PrevPrev Go to previous topic
NextNext Go to next topic
Last Post 11 Nov 2009 08:20 AM by  ross@reiusa.net
Available memory
 2 Replies
Sort:
You are not authorized to post a reply.
Author Messages
magene
New Member
New Member
Posts:


--
30 Nov 2008 12:32 PM
    I'm writing a WinCE 5.0 Visual Studio 2005 C/C++ application that makes use of the CSPI port, GPIO and needs as much RAM for data storage as I can get. After a lot of fumbling around I've got the CSPI port and the GPIO working. Unfortunately, I'm stuck on what I thought would be the easy part. I can't dimension more than about 12,000 unsigned integers. Seems like the memory is there. When I go to Settings->Control Panel->System->Memory, I have 29436KB of Storage Memory and 64768KB of Program Memory and I can move the division around with SetSystemMemoryDivision. Right now I'm just doing a brute force

    unsigned int value[15000]

    Everything is fine when I dimension 12,000 values. When I dimension 15,000, the VS2005 debugger says

    Unhandled exception at 0x03fbe678 in diskTest.exe: 0xC00000FD: Stack overflow.

    and the output window says

    [Stack fault]: Thread=879304f0 Proc=8210c690 'diskTest.exe'
    AKY=00002001 PC=03fbe678(coredll.dll+0x0004e678) RA=0001189c(diskTest.exe+0x0000189c) BVA=1c0312a4 FSR=00000807
    Unhandled exception at 0x03fbe678 in diskTest.exe: 0xC00000FD: Stack overflow
    .


    Seems pretty clear I have to make more memory available but I'm not sure where or how. Any suggestions will be greatly appreciated.

    Thanks - Gene
    AlanREI
    New Member
    New Member
    Posts:


    --
    15 Dec 2008 02:50 PM
    Your problem could be that Windows CE 5.0 limits each process to 32 MB of memory. You can use the other memory by declaring shared memory such as memory mapped files.

    this link about the memory architecture differences between CE 6 and 5 will help you.
    http://www.addlogic.se/ar...ry-architecture.html

    edit: Keep in mind there's some fragmentation going on also.. so you won't get close to a 32 MB continuous chunk either. Although, one 60 K chunk should be very easy (unless you are allocating lots of these)
    ross@reiusa.net
    New Member
    New Member
    Posts:


    --
    11 Nov 2009 08:20 AM
    I'm sure this is very late for the OP, but maybe it will help someone else:

    As Alan said, on CE 5.0, each process is limited to 32MB of address space. However, you can get around that and allocate large blocks of memory by using the Windows VirtualAlloc and VirtualFree funtions. To allocate memory in the shared memory space (which has 1 GB of address space in CE... more than enough for the i.MX31,) use the following 2 calls to VirtualAlloc():

    byte* buff = (byte*)VirtualAlloc(NULL, <number of bytes to alloc>, MEM_RESERVE, PAGE_NOACCESS);
    if (buff != NULL) // check to make sure the first call succeeded before making second call!
    {
    buff = (byte*) VirtualAlloc(buff, <number of bytes to alloc>, MEM_COMMIT, PAGE_READWRITE);
    }

    Note that the last 2 parameters MUST be the values shown here for the memory to be correctly allocated outside of the process' memory space. Also, the buffer size must be at least 2 MB in order for it to be allocated outside of the process' space, IIRC. Here's the MSDN documention for the functions:

    VirtualAlloc: http://msdn.microsoft.com...ibrary/aa450975.aspx
    VirtualFree: http://msdn.microsoft.com...ibrary/aa450979.aspx

    Note that to do this inside a .NET CF application, you will need to P/Invoke these functions. The P/Invoke declarations are as follows:

    [DllImport("coredll.dll")]
    public static extern bool VirtualFree(void* lpAddress, uint dwSize, VirtualFreeFlags flags);

    [DllImport("coredll.dll")]
    public static extern void* VirtualAlloc(void* lpAddress, uint dwSize, VirtualAllocType type, VirtualAllocFlags flags);

    public enum VirtualFreeFlags : uint
    {
    MEM_DECOMMIT = 0x4000,
    MEM_RELEASE = 0x8000
    }
    public enum VirtualAllocType : uint
    {
    MEM_COMMIT = 0x1000,
    MEM_RESERVE = 0x2000,
    MEM_RESET = 0x80000,
    MEM_TOP_DOWN = 0x100000
    }
    public enum VirtualAllocFlags : uint
    {
    PAGE_NOACCESS = 0x01,
    PAGE_READONLY = 0x02,
    PAGE_READWRITE = 0x04,
    PAGE_EXECUTE = 0x10,
    PAGE_EXECUTE_READ = 0x20,
    PAGE_EXECUTE_READWRITE = 0x40,
    PAGE_EXECUTE_WRITECOPY = 0x80,
    PAGE_GUARD = 0x100,
    PAGE_NOCACHE = 0x200
    }
    You are not authorized to post a reply.