Thread: memory/target help

  1. #1
    Registered User
    Join Date
    Dec 2006
    Posts
    2

    memory/target help

    I'm targeting a small linux system; but have been testing my basic functionality compiling for 16 bit dos so I can do windows type stuff at the same time I run my prog. Using um Borland 5.02.

    When I tried to use a STL 'list', I ran into th 64k text segment limit problem but changed the target type to medium which fixed it for the time being

    Unfortunately push_back crashes my program after putting about 3000 items in. I need to hold at least 30,000 preferably 120,000 elements to be safe. I'm trying to work directly with a fair sized chunk of a 300x400 image. Could this be related to my choice of targets? Would recompiling with g++ in linux be likely to help? Is there something I can do to fix it while staying in windows? Any insight would be appreciated.

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    why not to use some modern 32-bit compiler? there are several free on windows?

    and why not to check the result of memory allocations instead of crashing?
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > I'm targeting a small linux system
    However small it is, is it really 16-bit ?

    Also, define "small"
    My phone is pretty small, but it's still a 32 bit machine with several megs of memory.

    As vart says, there are plenty of good quality and free 32 bit compilers for windows.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  4. #4
    Registered User
    Join Date
    Dec 2006
    Posts
    2
    Small=large imbedded. yeah; is wdlinux and I guess that's probly 32 bit; and can hold lots of ram; but I dont have it here to see how much is actually in there. But neither of you indicated you think that is the source of my problem anyway, so I don't really understand why you ask.

    How do I check if push_back will work before calling it? Since I'm not personally allocating any memory and all I kinda assumed the STL code would take care of it.

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    For all the container classes defined by STL, if an exception is thrown during calls to the following member functions:

    insert // single element inserted
    push_back
    push_front
    the container is left unaltered and the exception is rethrown.
    so you should catch exceptions to know if the push_back was succesful
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > Unfortunately push_back crashes my program after putting about 3000 items in.
    Perhaps if you post a short program which crashes, we could tell you where you're messing up.

    Maybe it's nothing at all to do with memory allocation, and it's all down to some other unrelated mistake.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed