Hello!
I'm working on a Symbian Server.
It is possible to use EPOCHEAPSIZE to pass LowMem Test?
I mean: My Server will only start if there is enough memory available. I
known that this is not a good practice, but we use
C++ Standard Layer / Symbian C++ Layer architecture to facilitate porting to
other platforms. At the moment we detect memory errors very easily tracing
the log file (although is not best apporach).
Thank You very much for your support!
"Alfredo Rueda" <[email protected]> wrote in message
news:[email protected]...
> Hello!
>
> I'm working on a Symbian Server.
> It is possible to use EPOCHEAPSIZE to pass LowMem Test?
No, EPOCHEAPSIZE will set limits to the minimum and maximum sizes the heap
will be. The memory isn't pre-allocated
> I mean: My Server will only start if there is enough memory available. I
> known that this is not a good practice, but we use
> C++ Standard Layer / Symbian C++ Layer architecture to facilitate porting
> to other platforms. At the moment we detect memory errors very easily
> tracing the log file (although is not best apporach).
This sounds like your architecture expects a device with infinite resources.
--
Sander van der Wal
www.mBrainSoftware.com
>
> Thank You very much for your support!
The Symbian Server I'm working on consumes a maximum of 290 Kbytes of Heap
Memory (experimental measurement).
Although it's true that the code expects a device with infinite resources,
in the sense that does not handle memory errors (always supposes that "new"
C++ operator works well).
It's not the right way. What do you suggest me to pass LowMem Test?
I'm thinking that using std::set_new_handler() will be easy to satisfy the
LowMem requirements, but I suppose that Symbian does not support
std::set_new_handler().
Which techniques do you suggest me to pass LowMem requirements for both
Standar C++ code and Symbian C++ code?
I suppose that error handling code must be different in both layers because
Symbian has its own Exception Handling and Cleanup Mechanism Systems. Also
it's important to note that the Server has been ported succesfully to
Windows and Linux platforms so, the technique used to handle memory errors
must be compatible with other platforms (to ensure that Standard C++ code
remains cross platform).
Thank you very much for your patience and advices.
"Sander van der Wal" <[email protected]> escribi� en el mensaje
news:[email protected]...
>
> "Alfredo Rueda" <[email protected]> wrote in message
> news:[email protected]...[color=green]
>> Hello!
>>
>> I'm working on a Symbian Server.
>> It is possible to use EPOCHEAPSIZE to pass LowMem Test?
>
> No, EPOCHEAPSIZE will set limits to the minimum and maximum sizes the heap
> will be. The memory isn't pre-allocated
>
>> I mean: My Server will only start if there is enough memory available. I
>> known that this is not a good practice, but we use
>> C++ Standard Layer / Symbian C++ Layer architecture to facilitate porting
>> to other platforms. At the moment we detect memory errors very easily
>> tracing the log file (although is not best apporach).
>
> This sounds like your architecture expects a device with infinite
> resources.
>
>
> --
> Sander van der Wal
> www.mBrainSoftware.com
>
>>
>> Thank You very much for your support!
>
>
>[/color]
"Alfredo Rueda" <[email protected]> wrote in message
news:[email protected]...
> The Symbian Server I'm working on consumes a maximum of 290 Kbytes of Heap
> Memory (experimental measurement).
>
> Although it's true that the code expects a device with infinite resources,
> in the sense that does not handle memory errors (always supposes that
> "new" C++ operator works well).
>
> It's not the right way. What do you suggest me to pass LowMem Test?
I would suggest rearchitecturing te compatability layer. You can introduce
OOM exceptions/leaves,/error returns. Or, in the case that the memory needs
of the server are *known* to have an upper bound, you can allocate that
memory at server startup and use a dedicated memory allocater instead of the
generic one. This is especially usefull if the amount of memory used is
nearly always close to the *known* upper limit.
> I'm thinking that using std::set_new_handler() will be easy to satisfy the
> LowMem requirements, but I suppose that Symbian does not support
> std::set_new_handler().
I don't think so, no. If there is no memory, there is no memory, and there
is nothing you can do about it.
What LowMem checks is that application startup doesn't leak memory. I do not
see std::set_new_handler() being able to help you out here.
> Which techniques do you suggest me to pass LowMem requirements for both
> Standar C++ code and Symbian C++ code?
> I suppose that error handling code must be different in both layers
> because Symbian has its own Exception Handling and Cleanup Mechanism
> Systems.
If you are targetting Symbian 9.1, you can use C++ exceptions throughout.
> Also it's important to note that the Server has been ported succesfully to
> Windows and Linux platforms so, the technique used to handle memory errors
> must be compatible with other platforms (to ensure that Standard C++ code
> remains cross platform).
Your problem is that you are targetting the most powerfull of the possible
devices you want the program to run on, instead of the least powerfull one.
In terms of available memory, Symbian OS (and Windows Mobile and Palm OS and
Linux on Smartphones!) are not as powerfull as desktop OS'es. If your code
has to run succesfully on all of these devices, you should go for the lowest
common denominator and not for the top end.
--
Sander van der Wal
www.mBrainSoftware.com
>
> Thank you very much for your patience and advices.
>
>
>
>
>
> "Sander van der Wal" <[email protected]> escribi� en el mensaje
> news:[email protected]...[color=green]
>>
>> "Alfredo Rueda" <[email protected]> wrote in message
>> news:[email protected]...[color=darkred]
>>> Hello!
>>>
>>> I'm working on a Symbian Server.
>>> It is possible to use EPOCHEAPSIZE to pass LowMem Test?
>>
>> No, EPOCHEAPSIZE will set limits to the minimum and maximum sizes the
>> heap will be. The memory isn't pre-allocated
>>
>>> I mean: My Server will only start if there is enough memory available. I
>>> known that this is not a good practice, but we use
>>> C++ Standard Layer / Symbian C++ Layer architecture to facilitate
>>> porting to other platforms. At the moment we detect memory errors very
>>> easily tracing the log file (although is not best apporach).
>>
>> This sounds like your architecture expects a device with infinite
>> resources.
>>
>>
>> --
>> Sander van der Wal
>> www.mBrainSoftware.com
>>
>>>
>>> Thank You very much for your support!
>>
>>
>>[/color]
>
>[/color]
Hi Sander
Re this
> No, EPOCHEAPSIZE will set limits to the minimum and maximum sizes the heap
> will be. The memory isn't pre-allocated
You're correct - see FAQ 1253
http://www3.symbian.com/faq.nsf/AllByDate/8D0ADFE56F81F7FD80256FD400551095?OpenDocument
For my information only, .... why couldn't you use this to pass Lowmem? If
you set the minimum heap size to your maximum usage then the application
won't even try to start until you've guaranteed you have sufficient memory
for it to start all the way.
(Of course this is terrible design, and your other recommendations are a
much better way to solve this)
Regards
H
"Sander van der Wal" <[email protected]> wrote in message
news:[email protected]...
>
> "Alfredo Rueda" <[email protected]> wrote in message
> news:[email protected]...[color=green]
> > Hello!
> >
> > I'm working on a Symbian Server.
> > It is possible to use EPOCHEAPSIZE to pass LowMem Test?
>
> No, EPOCHEAPSIZE will set limits to the minimum and maximum sizes the heap
> will be. The memory isn't pre-allocated
>
> > I mean: My Server will only start if there is enough memory available. I
> > known that this is not a good practice, but we use
> > C++ Standard Layer / Symbian C++ Layer architecture to facilitate[/color]
porting[color=green]
> > to other platforms. At the moment we detect memory errors very easily
> > tracing the log file (although is not best apporach).
>
> This sounds like your architecture expects a device with infinite[/color]
resources.
>
>
> --
> Sander van der Wal
> www.mBrainSoftware.com
>[color=green]
> >
> > Thank You very much for your support!
>
>
>[/color]
"Hamish Willee" <[email protected]> wrote in message
news:qtOX%[email protected]...
> Hi Sander
>
> Re this[color=green]
>> No, EPOCHEAPSIZE will set limits to the minimum and maximum sizes the
>> heap
>> will be. The memory isn't pre-allocated
>
> You're correct - see FAQ 1253
> http://www3.symbian.com/faq.nsf/AllByDate/8D0ADFE56F81F7FD80256FD400551095?OpenDocument
>
> For my information only, .... why couldn't you use this to pass Lowmem? If
> you set the minimum heap size to your maximum usage then the application
> won't even try to start until you've guaranteed you have sufficient memory
> for it to start all the way.[/color]
If I could state the startvalue Lowmem should use when it tries to start an
app, I can always arrange the startvalue to be so big that all my startup
code memory leaks stay hidden.
--
Sander van der Wal
www.mBrainSoftware.com
> (Of course this is terrible design, and your other recommendations are a
> much better way to solve this)
>
> Regards
> H
>
>
> "Sander van der Wal" <[email protected]> wrote in message
> news:[email protected]...[color=green]
>>
>> "Alfredo Rueda" <[email protected]> wrote in message
>> news:[email protected]...[color=darkred]
>> > Hello!
>> >
>> > I'm working on a Symbian Server.
>> > It is possible to use EPOCHEAPSIZE to pass LowMem Test?
>>
>> No, EPOCHEAPSIZE will set limits to the minimum and maximum sizes the
>> heap
>> will be. The memory isn't pre-allocated
>>
>> > I mean: My Server will only start if there is enough memory available.
>> > I
>> > known that this is not a good practice, but we use
>> > C++ Standard Layer / Symbian C++ Layer architecture to facilitate[/color]
> porting[color=darkred]
>> > to other platforms. At the moment we detect memory errors very easily
>> > tracing the log file (although is not best apporach).
>>
>> This sounds like your architecture expects a device with infinite[/color]
> resources.
>>
>>
>> --
>> Sander van der Wal
>> www.mBrainSoftware.com
>>[color=darkred]
>> >
>> > Thank You very much for your support!
>>
>>
>>[/color]
>
>[/color]
Hi Sander
> If I could state the startvalue Lowmem should use when it tries to start
an
> app, I can always arrange the startvalue to be so big that all my startup
> code memory leaks stay hidden.
You can't change the startvalue of Lowmem, but you can use this to change
the value at which your program will start at all, and therefore you would
meet the requirements of the test
* "application gracefully handles low memory situations during startup" -
because it won't start under low memory conditions
* "When exiting under low memory application displays appropriate error
messages. - should do, because it can't exit
I'm not in any way advocating this approach, as any code using it to pass is
still bad code. What I'm trying to establish is whether my understanding of
the API behaviour is correct.
Regards
H
Thank You Hamish Hamish Willee and Sander van der Wal, for your suggestions.
I'm still a bit confused.
I invite everybody to post your experiences and suggestions.
I can't use Standard C++ Exceptions, because the code must be compatible
with older Symbian Versions.
Thank you and have a nice weekend!
"Hamish Willee" <[email protected]> escribi� en el mensaje
news:[email protected]...
> Hi Sander
>[color=green]
>> If I could state the startvalue Lowmem should use when it tries to start
> an
>> app, I can always arrange the startvalue to be so big that all my startup
>> code memory leaks stay hidden.
>
> You can't change the startvalue of Lowmem, but you can use this to change
> the value at which your program will start at all, and therefore you would
> meet the requirements of the test
> * "application gracefully handles low memory situations during startup" -
> because it won't start under low memory conditions
> * "When exiting under low memory application displays appropriate error
> messages. - should do, because it can't exit
>
> I'm not in any way advocating this approach, as any code using it to pass
> is
> still bad code. What I'm trying to establish is whether my understanding
> of
> the API behaviour is correct.
>
> Regards
> H
>
>[/color]
Hi Alfredo
"Although it's true that the code expects a device with infinite resources,
in the sense that does not handle memory errors (always supposes that "new"
C++ operator works well)."
That is not an assumption you can make on a Symbian OS device. Its not a
matter of "new" working well - new will either allocate the memory or it
will return NULL. You need to check and handle in some way.
On Symbian OS new is by default overloadled so you can use new (ELeave) to
do all the code for checking whether the value is NULL, and if so, to throw
a :Leave.
Sander's first suggestion is that you re-architect your compatability layer
to introduce OOM exceptions/leaves,/error returns. I'd interpret this as
perhaps overloading "new" to either do normal new or C++ exceptions on other
platforms, and C++ exceptions/new (ELeave) on Symbian OS.
Sander, any opinion on the viability of that/any further guidance
Sander's other suggestion was that in the case that the memory needs
of your code are *known* to have an upper bound, you can pre-allocate that
memory at startup and use a dedicated memory allocater instead of the
generic one.
This has the advantage that you have the memory you need allocated at
startup; you won't run out unless your application is leaking memory (which
it probably is if you don't have anything in place to check this!), and even
it if does, you can handle this in one place ... the allocator.
The reason you shouldn't use EPOCHEAPSIZE with a minimum value of enough to
get your application started is that yes, you may pass this test, but once
started your application won't handle other OOM errors, and if you're
leaking memory this will affect every other app.
Hope that clarifies.
Regards
H
"Alfredo Rueda" <[email protected]> wrote in message
news:[email protected]...
> Thank You Hamish Hamish Willee and Sander van der Wal, for your
suggestions.
> I'm still a bit confused.
> I invite everybody to post your experiences and suggestions.
>
> I can't use Standard C++ Exceptions, because the code must be compatible
> with older Symbian Versions.
>
> Thank you and have a nice weekend!
>
>
>
>
>
>
> "Hamish Willee" <[email protected]> escribi� en el mensaje
> news:[email protected]...[color=green]
> > Hi Sander
> >[color=darkred]
> >> If I could state the startvalue Lowmem should use when it tries to[/color][/color]
start[color=green]
> > an[color=darkred]
> >> app, I can always arrange the startvalue to be so big that all my[/color][/color]
startup[color=green][color=darkred]
> >> code memory leaks stay hidden.
> >
> > You can't change the startvalue of Lowmem, but you can use this to[/color][/color]
change[color=green]
> > the value at which your program will start at all, and therefore you[/color]
would[color=green]
> > meet the requirements of the test
> > * "application gracefully handles low memory situations during[/color]
startup" -[color=green]
> > because it won't start under low memory conditions
> > * "When exiting under low memory application displays appropriate error
> > messages. - should do, because it can't exit
> >
> > I'm not in any way advocating this approach, as any code using it to[/color]
pass[color=green]
> > is
> > still bad code. What I'm trying to establish is whether my understanding
> > of
> > the API behaviour is correct.
> >
> > Regards
> > H
> >
> >
>
>[/color]