Checking stack size

I have written a JNI app and it seems to work fine, but processing with very large files I run out of stack space.
I have solved this issue for the moment by changing the stack size with the -Xss param to java but this is not the ideal issue because with even bigger files I still will have issues.
So, I have 3 questions:
1. Is there any way (in the c++ dll) to query the total stack size ?
2. Is there any way to determine free (available) stack size ?
3. Is there any way to increase the stack size when the dll is already running (if it starts to get low)
I look forward to your thoughts
Ding

I have written a JNI app and it seems to workfine,
but processing with very large files I run out
of
stack space.
That suggests that you have a design problem.
As a guess you are using recursion. Start by
unrolling the recursion code to produce a
non-recursive solution.ood Guess but there is no recursion in my code :-)
While I am always trying to optimize my design, in
this case I am constrained by 3rd party c libraries
that are using very large multi dimensional arrays of
doubles that are neccessary for lots of complicated
math doing triangualtion of satellite data. So, I
have no control over how much memory they want to
consume.
ood Guess but there is no recursion in my code :-)
Then it is unclear as to what you think a good solution would entail.
Do you intend to just to keep retrying the processing step with ever increasing stack sizes? Will that not impact the processing time? Why not just start with a larger stack size? And if the stack size just continues to grow because the file sizes are continuing to grow then what?
While I am always trying to optimize my design, in
this case I am constrained by 3rd party c libraries
that are using very large multi dimensional arrays of
doubles that are neccessary for lots of complicated
math doing triangualtion of satellite data. So, I
have no control over how much memory they want to
consume.
One solution would be to create a C app, not a java one. Find the maximum amount of stack space that you can allocate via a C app and still operate (this depends on what happens with the file itself.) The output goes to a file.
Your java app just starts that in a separate process space.
>>
>
I was referring to the native C stack, used within
the c++ dll, for which the java VM starts via the
-Vss flag. I know the initial total as I am setting
it at runtime. I just wanted to print the value from
within the dll. #2 (below) is more important
though.
That would depend on your OS and compiler.
2. Is there any way to determine free(available)
stack size ? This is the part I was mostly hoping for an answer
to, as I need to communicate with the parent java app
if the stack space gets too low, instead of just
allowing the dll to crash when it runs out
That is a two part question. You want to know the size and you want to know if it gets 'too low'.
You suggested that this is all stack based processsing. So unless you have C methods that are called by the library and in addition it is recursive in nature then this is not possible. There is no point where you could detect it.
You can analyze the file yourself and compute a size before you start processing. But if that is what you are doing then you should do it first and let the java app know the result.
Other than that most OSes allow you to catch 'system exceptions' (which might or might not be actual C++ exceptions.) One of these would be generated when the stack overflows.
You then convert into something that java understands.
For example in Windows there is a function that allows you to set up system exceptions so that they cause a C++ exception to be thrown. You would then catch this exception and convert it into a java exception.
That lets you know that it didn't work but then what?
For example in windows you can create a custom stack for the dll but only when the dll loads (so far as I know.) So to restart this you would have to unload the dll and that means that you will have to have everything wrapped in a custom class loader (which is the only way to cause a dll to be unloaded.)
Not to mention that in my experience the windows function that I mentioned above doesn't necessarily always catch everything.
>>>
>>
No. The VM must be restarted.if that is true, It i a bummer :(You can however, on most OSes, increase the stack size for the shared library. This is done on start up of the shared library. To resize it however means that the shared library must be reloaded. And the only way you can do that in the Sun VM is with a class loader.

Similar Messages

  • How can I increase the hard limit of the stack size?

    Hi,
    My process gives an error of segmentation fault (SIGSEGV) that is caused because the stack limit is reached. I have a doubt about how to increase the stack size. I have tried change it with "ulimit - hard" but this size is 65532kb, and is very low for my process. How can I increase the hard limit?
    Thanks.

    When last I checked, the kernel had a fixed stack size limit.
    Do you have the source code to this application? If so, [see this Tiger stack size article|http://homepage.mac.com/eric.c/hpc/contents/documentation/How%20to%20in crease%20the%20stack%20size%20on%20Mac%20OS%20X.pdf], and specifically have a look at the +ld -stack_size+ mechanism; rebuild the code with a bigger limit.
    Entirely FWIW, this question would be more typical over in the developer forums or maybe in the Unix forum if you don't have Apple developer access. Better audience for application development and for software-related questions over there.

  • Default stack size vs. -Xss option

    Hi,
    What the default stack size?
    That is, if you use the -Xss<size> option, it will set the stack
    size to <size>, but what is the default. I've searched and only
    found one posting that says it is 256k.
    http://forum.java.sun.com/thread.jsp?forum=256&thread=40530
    Is that correct? Since this is a JVM option, is it platform
    dependant? In that case, what would it be on Win2k and Solaris?
    We are serializing graph objects and getting a StackOverflowError
    on occassion. There is a well known bug about this:
    http://developer.java.sun.com/developer/bugParade/bugs/4152790.html
    Thanks.
    --- Patrick

    Hi,
    It depends on version and OS.
    In Solaris there is in addition the OS restriction in ulimit
    or maxssiz in HP.
    hurricane% ulimit -a
    time(seconds) unlimited
    file(blocks) unlimited
    data(kbytes) unlimited
    stack(kbytes) 8192
    coredump(blocks) unlimited
    nofiles(descriptors) 4096
    vmemory(kbytes) unlimited
    Workaround - Use "ulimit -s 2048" in bash shell or "limit stacksize 2048" in tcsh to limit the initial thread stack to 2 MB.
    http://java.sun.com/docs/hotspot/VMOptions.html
    Check the link for the Solaris defaults.

  • Desired stack size of 8197 Kb exceeds current process limit of 8192 Kb.

    I've installed HP's JDK on my hp box:
    HP-UX HPUX B.11.23 U ia64
    However, I noticed that when I got some error just type "javac":
    # java -version
    java version "1.5.0.06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0.06-_12_jan_2007_03_27)
    Java HotSpot(TM) Server VM (build 1.5.0.06 jinteg:01.12.07-08:49 IA64, mixed mode)
    # javac
    Java HotSpot(TM) Server VM warning: Desired stack size of 8197 Kb exceeds current process limit of 8192 Kb.
    Well, I could compile and execute java programs on this box, but I'm curious to know the cause for the error message.
    Thanks,
    Tuan

    What is your ulimit set to ?
    e.g.
    $ ulimit -a
    stack(kbytes) 8192
    Check your kernel limit with :
    e.g.
    # kctune | grep maxssiz
    maxssize 8388608
    maxssize_64 268435456
    So you could boost it by changing the maxssize kernel parameter.
    Hope this helps,
    Lee

  • Increase of Stack size impact

    Hi there,
    Please, what is the impact of increasing the Stack size with the -Xss option for the whole system. is there any relationship or formula between -Xms, -Xmx and -Xss options.
    Is it necessary to increase the -Xmx option When i increase the -Xss option.
    I'm using Weblogic 9.1 within a machine of 16GB under AIX 64bits and IBM JVM. My parameters are : -Xms=-Xmx=1GB and i think pass the -Xss to 1MB because i get many StackOverflow exceptions.
    Think you for your help

    hi,
    Changing the fonts in Print using ABAP is not possible. as basic report output is a text editor.
    By changing "Customizing of Local Layout" will only change in display screen and not in print.
    One possible way to create a new printer formatr thry SPAD and use that format in while printing.
    to know more details about SPAD
    Using SPAD - SAP Spool Administration to print different paper size
    The SAP spool system manages its own output devices. This includes mostly printers, but also fax and archiving devices. In order for you to use output devices defined in your operating system from the SAP System, you must define these devices in the SAP spool system.
    this is a piece of code from SAP-IMG ...its about printing fonts...see if this helps u....
    REPORT ZFONT NO STANDARD PAGE HEADING LINE-SIZE 80 LINE-COUNT 65.
    Start of print-control
    NEW-PAGE PRINT ON.
    PRINT-CONTROL FUNCTION 'SF000'.
    WRITE: / 'This is CPI 20'.
    SKIP.
    PRINT-CONTROL FUNCTION 'SF020'.
    WRITE: / 'This is CPI 6'.
    SKIP.
    PRINT-CONTROL FUNCTION 'SF008'.
    WRITE: / 'This is CPI 12'.
    Depending on your SAP printer device, this may also work
    PRINT-CONTROL FONT 1 LPI 6.
    you can try to change font and LPI numbers
    WRITE: / 'font 1 lpi 6'.
    PRINT-CONTROL FONT 2 LPI 6.
    WRITE: / 'font 2 lpi 6'.
    PRINT-CONTROL FONT 3 LPI 6.
    WRITE: / 'font 3 lpi 6'.
    End of print-control
    NEW-PAGE PRINT OFF.
    *--- End of Program
    also check out these links:
    For More Info Go thru this Link,
    font size in basic list output
    http://www.sapdesignguild.org/resources/MiniSG-old/BCMSG03E_DEL.htm
    http://sap4.com/modules.php?name=conteni2&pa=showpagina&pid=100
    do reward points if it helps
    rgds

  • -Xss: Stack size too large

    There is a requirement of high stack size in the application but when I try to set the stack size > 128m , I get the below error
    [ERROR] Argument error: -Xss130m
    [ERROR] -Xss: Stack size too large
    Could not create the Java virtual machine.
    Is there a upper limit of 128m on stack size. The Jrockit version is 64 bit.
    Please help

    Hi,
    Are you running OS in 32 bit or 64 bit.
    eg:
    O/S 32-bit Default 64-bit Default
    Windows 64 kB 320 kB
    Linux 128 kB 1 mB
    Please check your stack size you mentioned it is 128m please change to KB it will work.
    Regards,
    Kal

  • Pixma 330 fax output error check paper size

    I received a fax on my Pixma 330. The document came through fine, but now I have "fax output error, check paper size and press OK". The paper size is correct, and when I press OK, it prints out the original document again, then gives me the same error message. If I turn off the machine, when I turn it back on, it again prints the document, then gives me the error message. The machine will not let me do anything except press OK. How can I get this to go away? Thanks.

    Hi JWK,
    Please make sure that the paper is loaded correctly and the settings are correct.  To do this, please follow these steps:
    1. Flatten the four corners of the paper before loading it.
    Note
    Align the edges of paper neatly before loading. Loading paper without aligning the edges may cause paper jams.
    If paper is curled, hold the opposing curled corners and gently bend them in the opposite direction until the paper becomes completely flat. See Paper is curled..
    To avoid curling, handle paper as follows.
    - When you do not print, remove unused paper from the Rear Tray, put them back into the package, and keep it on a level surface.
    - Take out only the necessary number of sheets from the package, just before printing.
    2. Load the paper.
    (1) Open the Paper Support, raise it, then tip it back.
    (2) Open the Paper Output Tray gently, and open the Output Tray Extension.
    (3) Slide the Paper Guides (A) to open them, and load the paper in the center of the Rear Tray WITH THE PRINT SIDE FACING YOU
    Important
    Always load paper in the portrait orientation (B). Loading paper in the landscape orientation (C) can cause paper jams.
    (4) Slide the Paper Guides (A) to align them with both sides of the paper stack.
    Do not slide the Paper Guides too hard. The paper may not be fed properly.
    Note:
    Do not load sheets of paper higher than the Load Limit Mark(D).
    After loading paper
    When using the machine to copy or print without a computer, select the size and type of the loaded paper in Page size and Media type of the settings screen in each mode.
    If you continue to have difficulties, please contact our support group using the following link:
    http://www.usa.canon.com/cusa/consumer/standard_display/contact_us_consumer
    Did this answer your question? Please click the Accept as Solution button so that others may find the answer as well.

  • Cannot increase the stack size

    Hi,
    We have a program which gives a StackOverflowError. Trying the increase the stack size using command line options does not work. A simple program shows that the stack is the same size, whatever option we set.
    This is the program:
    class StackOverflowTest
    public static int counter = 0;
    public static void main(String[] a)
    try {
    sub();
    } catch (StackOverflowError e)
    System.out.println("recursive calls: "+counter);
    public static void sub()
    counter++;
    sub();
    We tried several -Xss (and -Xoss) settings: 600K, 2048K, 4M but got the same recursion deep: 16683 (with Eclipse), or 16689 (command line).
    We used Windows XP.
    Do you have any clue?
    Many thanks,
    Zsolt

    Oh good, they seem to have broken the forum formatting again.
    ====================================================================================================================
    Bug ID:     4362291     Stack size argument ignored (-Xss and -ss)
    ====================================================================================================================
    public class StackOverflowTest {
        public static int counter = 0;
        public static final void main(String[] a) {
            new Thread(new Runnable() {
                public void run() {
                    try {
                        sub();
                    } catch (StackOverflowError e) {
                        System.out.println("recursive calls: "+counter);
            }).start();
        public static final void sub() {
         counter++;
         sub();
    /code]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Check the size of uploaded file in Oracle UCM

    I need to check the size of the uploaded primary file in Oracle UCM during checkin. I tried writing a filter on the event validateStandard and check the value of dFileSize. But the value is null. Any ideas what event should I use and which parameter should I check?

    hi,
    I am new to Oracle UCM. I need same functionailty of checking file size of uploaded content. Could you please elaborate how you achieved it..... thanx in advance.

  • Change the default stack size in the java.exe file

    Does anyone know how to change the default stack size of the jvm?
    I'm having problems with my stack. Is there anyway I can change it. I found a tool editbin.exe which is shipped with Visual c++, however I don't have the tool.
    Thanks,
    William

    I am using JNI to connect java with a C++ application.
    When calling the C++ appliction, STACK_OVERFLOW
    happends. I tried java -Xss<size> to increase the
    stack size, but failed.This has nothing to do with the above question.
    Does anyone knows why?Probably because the java parameter specifies the java stack size and not the C++ stack size.

  • How to check File size of a Text file.

    How to check File size of a Text file.
    please explain me.
    I am new in LabVIEW. and dont have much idea on this...;
    Prashant Soni
    LabVIEW Engineer
    Solved!
    Go to Solution.

    Hi Prashant,
    and here's what you get when using the LV help...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Checking Trim size Quickly

    Hi there, small thing, I've out up with it for years but it strikes me as weird that this may never have been requested or that there is no option for it.
    In the preferences there is an option to always display the pdf size. Well that's great but as someone in prepress I'm not really interested in the media/cropbox size, I'm interested in the trim size. So ideally there should be a preference to set the displayed size to trimbox, not total pdf size.
    So I usually go to Set Page Boxes to check the size. The dropdown defaults to Cropbox so I have to set that to Trimbox, and then I finally know if the trimbox is actually what the client/rep/whoever has told me the size is (sometimes it isn't). Is there a way to make that dialogue box default to Trimbox?
    Of couse if I could set a preference to always display the trimbox size on any open pdf I wouldn't even have to go into that dialogue box.
    So... Is there a way to solve either of those issues (recap: 1- always display trimbox in the bottom corner, not crop/media/whatever it's displaying 2- default Set Page Boxes dialogue to trimbox removing the need for one extra click - sounds lazy but it's irritating) already and I have missed them, or, should I put this in some feature request forum/list/whatever-I haven't explored how you do that yet...
    Is it weird that no one has ever bought this up or am I unusual?

    I'm also looking for a quick way to check the size of the trimbox. Currently my fastest way to check is with the PitStop Pro inspector. Open a PDF, alt-cmd-i. The inspector will default show its last used info. But unfortunately you'll need PitStop Pro.

  • How to check total size of attachment stored in database?

    Hello guys,
    Firstly I'm new to this forum & SAP Basis. Therefore i want to apologize if i'm posting in wrong area.
    Actually I want to know how to check total size of attachment that have been uploaded in ECC.
    From the current database size, how can i check how much space have been used to store attachment such as pdf, doc, xls and tif. I  want to know how much space have been utilized by those attachments from August 2010 until now.
    FYI, those are PR, PO & MIGO attachments.
    Where do i start? What are the tables to check? Which table keeps record of the attachment size? etc.. etc..
    Really appreciate if you guys can give me some guideline.
    Thank you & Rgds,
    fafizah.

    Hi,
    As such there is no direct way to do this but if you will able to find out which all table stores the attachment then you can find out the size of those table from database level.
    Thanks
    Sunny

  • HELP !!! How to check the size of an object in Photoshop ?

    Hello,
    I'm using Photoshop CS 3 to design a website. I used several shapes such as rectangle, line or ellipse of different size. Probably it is a stupid question but I don't know how to check the size of an existing rectangle. I tried free transform tool that selects my rectangle but doesn't show its size. Then I made a selection with rectangular marquee tool but I see nowhere the size of the selected area.
    If you know the name of such a tool please help me !
    Have a nice day !

    Web images are all pixels. View at 100% at pixel view. that is your exact size

  • Stack size for native thread attaching to JVM

    All:
    I have a native thread (see below, FailoverCallbackThread) that attaches to the JVM and does a Java call through JNI. The stack size for the native thread is 256KB.
    at psiUserStackBangNow+112()@0x20000000007a96d0
    at psiGuessUserStackBounds+320()@0x20000000007a8940
    at psiGuessStackBounds+48()@0x20000000007a8f60
    at psiGetPlatformStackInfo+336()@0x20000000007a9110
    at psiGetStackInfo+160()@0x20000000007a8b40
    at psSetupStackInfo+48()@0x20000000007a5e00
    at vmtiAttachToVMThread+208()@0x20000000007c88b0
    at tsAttachCurrentThread+896()@0x20000000007ca500
    at attachThread+304()@0x2000000000751940
    at genericACFConnectionCallback+400(JdbcOdbc.c:4624)@0x104b1bc10
    at FailoverCallbackThread+512(vocctx.cpp:688)@0x104b8ddc0
    at start_thread+352()@0x20000000001457f0
    at __clone2+208()@0x200000000030b9f0
    This causes stack overflow in Oracle JRockit JVM. (It does not cause overflow with Oracle Sun JDK.) Is there a recommended stack size for this use case for JRockit? Is there a way to compute it roughly?
    Platform Itanium 64 (linux)]
    java version "1.5.0_06"
    Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_06-b05)
    BEA JRockit(R) (build R26.4.0-63-63688-1.5.0_06-20060626-2259-linux-ia64, )
    mp

    How do I found default heap size, stack size for the
    thread, number of threads per jvm/process supported ?The threads is OS, OS install and jvm version specific. That information is also not useful. If you create the maximum number of threads that your application can create you will run out of memory. Threads require memory. And it is unlikely to run very well either.
    The default heap size and stack size are documented in the javadocs that explain the tools that come with the sun jdk.
    and how the above things will vary for each OS and how
    do I found ? Threads vary by OS, and OS install. The others do not (at least not with the sun jvm.)
    If I get "OutOfMemoryError: Unable to create new native thread" Most of the time it indicates a design problem in your code. At the very lease, you should consider using a thread pool instead.
    I found in one forum, in linux you can create maximum
    of 894 threads. Is it true ?Seems high since in linux each thread is a new process, but it could be.

Maybe you are looking for

  • Why do I need to reset my Airport Express multiple times a day?

    I purchased an Airport Express (AE) in 2008.  Ocassionaly since I've owned the device, I've had a problem connecting to it via iPod touch, iPhone, Macbook Pro, Macbook, etc.  I would see the AE in my wifi router list, I just couldn't connect to it. 

  • Excel file name with Time stamp, also from a template?

    Hi i created this little vi that opens an excel template, then populates it with pressure and temperature values. that part worked fine. My issue is i'd now like to rename that template file so i can append the current date and time. ive started off

  • Jsf compnent rendering

    I have the below code that displays the image before my table tags. Why does this render this way? table width="100%" border="0" cellpadding="0" cellspacing="0">                     <tr>                             <td width="20%"> <h:graphicImage va

  • Putting extra field

    Dear friends,    I need to add additional field ( MARA-MFRPN ) in the output report of Transaction MB52. The program name is RM07MLBS for MB52 , I copied the program, but i felt difficult to add this additional field. Pls brief me on this.

  • My problem happened after I downloaded latest version of itunes

    cant sync Iphone in itunes after downloading latest version of itunes