Runtime Stack Depth

I am writing some more "exotic" datastructures (AVL trees, Red-Black Trees). My main concern is the runtime stack depth. I don't want blow over it if i am inserting a large amount of data. Would the best approach be to write it procedurally instead of recursively?

Both AVL and Red-Black trees are balanced binary trees, so the maximum depth of the tree is 2 lg n, where n is the number of elements and lg is the logarithm base 2. To have a tree depth of 64, you'd need over 4 billion elements in your tree. For this to overflow even a 64 KB stack, you'd need to store 1 KB of local variables, or 256 ints, in your recursive method. The default stack depth is much bigger, usually 512 KB or 1 MB.
I wouldn't consider stack overflow in deciding whether to use recursion or iteration.

Similar Messages

  • Call stack depth

    Hello,
    i would like to know if there is any possibility in PL/SQL to get the current stack depth inoformation. I am not sure if this is the right description, i would like to know how deep into calling subprograms has a program execution come at the moment.
    I would like to use this information for automatical indentation of log file, produced by a pl/sql procedure call.

    948452 wrote:
    Can you please provide me with some sample code?Unable to read the documentation for some reason?
    SQL> ed
    Wrote file afiedt.buf
      1  create or replace procedure callme(x in number, y in number) is
      2    v_call_stack varchar2(32767);
      3  begin
      4    v_call_stack := dbms_utility.format_call_stack();
      5    dbms_output.put_line(v_call_stack);
      6    if x < y then
      7      callme(x+1,y);
      8    end if;
      9* end;
    SQL> /
    Procedure created.
    SQL> exec callme(1,5);
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    3F6E5040         4  procedure SCOTT.CALLME
    482416A0         1  anonymous block
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    3F6E5040         4  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    482416A0         1  anonymous block
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    3F6E5040         4  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    482416A0         1  anonymous block
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    3F6E5040         4  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    3F6E5040         7  procedure
    SCOTT.CALLME
    482416A0         1  anonymous block
    ----- PL/SQL Call Stack -----
      object      line  object
      handle    number  name
    3F6E5040         4  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    3F6E5040         7  procedure SCOTT.CALLME
    482416A0         1  anonymous block
    PL/SQL procedure successfully completed.

  • Subr stack depth exceeded

    Hello,
    makeotflib [WARNING] subr stack depth exceeded (reduced)
    Is this a problem of my feature code or more an information statment of
    MakeOTF?
    Anything to do?
    Andreas

    This is not a problem to worry about. It means that when MakeOTF tried to subroutinizedthis font in order to make it smaller, the font was so difficult that MakeOTFran out of the fixed reiteration depth, and as a result the analysis was not as complete as might have been possible. The result is that your font is fine, but may not be compressed to the theoretical maximum.

  • Verify Error 1030# Stack Depth unbalanced 1 != 0.

    Hi,
    Iam trying to inject some code into the SWF File using an
    opensource Java Framework. My code is getting injected correctly. I
    saw this, when i tried to decompile the SWF file into which i
    injected the code. But there is something that needs to be handled
    when it comes to handling the instruction sets available inside the
    method where i injected the code. I just wanted to know what that 1
    and 0 points to, in the below given error message.
    Verify Error 1030# Stack Depth unbalanced 1 != 0.
    If somebody can help me out in making me understand the 1 and
    0 in the error message, i can further proceed to correct the
    mistake that i have done.
    Thanks,
    Prabakaran Srinivasan.

    Hi All,
    I am able to find the root cause for this. For AS 3 classes,
    while parsing the ABC code, every method body will be a set of
    instructions in which each instruction will have an offset to it.
    This offset will be useful to mark the target for branching
    instructions like if, while etc.... Because, these instructions
    contains targetoffset as a parameter to which the instruction has
    to jump when the condition becomes true or false. The process what
    i am doing is i do some code injection to replace the URLRequest
    calls. The flash file in which i got this error, i did replace the
    URLRequest call to my own method call and this code was being
    wrapped up by an IF block. Because of the code injection, i need to
    update the offset of the instructions with the difference offset
    value. I did this, but i missed the jumpoffset parameter of the if
    block wrapping my injected code which was the root cause. I did fix
    this...
    Thanks,
    Prabakaran Srinivasan.

  • How to debug a runtime stack underflow error?

    I'm really struggling to resolve a stack underflow that I'm getting.  The traceback I get at runtime is:
    VerifyError: Error #1024: Stack underflow occurred.
    at flash.events::EventDispatcher/dispatchEventFunction()
    at flash.events::EventDispatcher/dispatchEvent()
    at flash.net::URLLoader/onComplete()
    This is particularly difficult to debug because when I run in debug mode it does not happen at all.  It only happens when compiled as a release.
    Does anyone have any tips on how to debug a Stack Underflow?  Are have a clean explanation of what that means for Flash?
    In case it helps, this error is occurring when I click a button whose handler makes an RPC call, which uses a URLLoader, an AsyncToken, and then invokes the set of AsyncResponder instances associated with the AsyncToken.  With some server-side logging as well as some logging hacked into the swf, I know that the UrlLoader is successfully doing and GET'ing a crossdomain.xml file, is correctly processing it (if I wreck it, I get a security error), and is also successfully completing the "load" request (the server sends the data)... the underflow seems to be happening in the Event.COMPLETE listening/handling process (as is, of course, implied by the traceback as well).
    mxmlc used = from flex_sdk_4.5.0.20967
    Example player (I've tried a few) = 10.2.153.1

    Peter Blazejewicz wrote:
    crossposted:
    http://stackoverflow.com/questions/6270837/how-to-debug-a-runtime-stac k-underflow-error
    Yes... I intended to say so here but didn't get to it yet.  View traffic was extremely low here and I thought I'd see how stackoverflow compared.  I tend to check there first for most languages usually, but thought I'd try here as well to see if I should break that habit.
    As per the SO post, my specific problem was resolved by switching my variable initialization routine from the "initialize" application event, to the onCompletion event.  Although I am obviously "happy" about this since this issue cost me a lot of time and hair, it does not really indicate how I would go about debugging such an internal error in the future, so the question is technically unanswered.
    As to the question from Flex harUI, I am compiling indirectly via the MXMLC in the SDK, through the Amethyst Visual Studio plugin (which I'm auditioning).  The only libraries involved are from the flex_sdk_4.5.0.20967 SDK.  The project is quite small (a test project), consisting only of 1 MXML file and 2x .AS files.

  • Forms Runtime stack dump - MSVCRT.dll

    I'm having trouble with a Forms 5.0 app that I'm bringing up to Forms 6i. Whenever I try to run the form, I get a stack dump. I searched METALINK and found lots of people complaining of the same or similar problem, all in forum threads that have since been closed without anyone posting a solution. Has anyone experienced this? I'm desperate for a solution!
    I'm running Windows/NT Build 1381, SP6, but the problem also occurs on a Win2k workstation. I've tried uninstalling/reinstalling all the Oracle products on my workstation, and I've also tried loading various different versions of MSVCRT.dll into the WINNT/system32 folder. (This is a pain because Windows opens & locks the DLL.)
    Thanks in advance.
    -- Rob
    Here's the stack dump:
    ===========================================
    [05/28/02 15:42:47 Pacific Daylight Time]::Client Status [ConnId=0, PID=258]
         >> ERROR: Abnormal termination, Error Code: C0000005 ACCESS_VIOLATION
    ======================= STACK DUMP =======================
    Fault address: 78001C89 01:00000C89
    Module: C:\WINNT\system32\MSVCRT.dll
    System Information:
    Operating System: Windows NT Version 4.0 Build 1381 Service Pack 6
    Command line: "C:\Oracle\Developer6i\BIN\ifrun60.EXE" pcar1000.fmx
    FORM/BLOCK/FIELD: :.
    Last Trigger: - (No error number)
    Last Builtin: - (No error number)
    Registers:
    EAX:00357365
    EBX:0012EC4C
    ECX:00357365
    EDX:00000000
    ESI:00732C70
    EDI:FFFFFFFF
    CS:EIP:001B:78001C89
    SS:ESP:0023:0012EB18 EBP:0012EB30
    DS:0023 ES:0023 FS:0038 GS:0000
    Flags:00010202
    Call stack:
    Address Frame
    78001C89 0012EB30 strlen
    67241539 0012EBE0 uiwnzAdjustApiSize
    6723D1F8 0012ED6C uiwnc
    5DF5E2CE 038838E4 exiterr

    We are experiencing the same problem.
    O.S - Windows NT Ver 5.0 service pack 2
    Designer 6.5.88.4.0
    Repository 6.5.88.12.0
    Headstart 6.5
    Oracle 8.1.7.1.1
    The generated forms are running fine in web mode but crashes out when you run it in
    client-server mode. We have peformed all the recommendations in Headstart installation manual.
    Help us please..

  • How does JVM know the method's stack depth?

    When a caller push several operands into its operand
    stack,how does the JVM know the number of the
    callee's parameters and pop correct number of operands
    out of the stack.

    It's determined by the signature of the method given in the invokestatic, invokevirtual, invokeinterface, or invokespecial bytecode.

  • Stack Overflow Exception

    Hi all,
    I am trying to serialize a directed graph. I have Node objects, and each Node object has a Vector of Node objects as one of its fields. The directed graph is stored as a Vector of Node Objects. The Node object and the DirectedGraph objects are structured as follows:
    public class Node
    private int nodeID;
    private Vector adjacentNodes;
    // Constructor..
    // Some more methods
    public class DirectedGraph
    private Vector nodes;
    // Other fields and methods.
    When the no of nodes is very large (~ 10000), I get a StackOverflow error, which I think is because of the recursive serialization. I do not get the exception for a small set of nodes (~1000).
    I did read someplace that if the stack depth is greater than 2000, the VM throws the exception.
    Are there any workarounds for this (without any changes to the data representation) ?
    Are there other custom serializers which detect infinite cycles ?
    Or, (worst case), do I have to write my own serializer?
    Suggestions, links, will surely help.
    Thank you,
    Astranomina

    As mentioned above, Java serialization handles a cyclic object graph by writing a representation of the object reference to the stream for subsequent occurrances, so this does not cause infinite recursion.
    However, if your structure has 25,000 levels then I'm not surprised that you got StackOverflow and for something this size I don't think that trying to increase the stack size is the way to go.
    As intimated by Ernimril, a better approach would be to devise a serialized form that is more sympathetic to the environment. I would recommend that you program to interface and use object replacements. That way, the issues regarding serialization can be hidden and coded in the appropriate place:
    public interface DirectedGraph
    public interface Node
    public class LocalDirectedGraph implements DirectedGraph
    // your current code (and the same for LocalNode)
    Object writeReplace() throws ObjectStreamException
      // flatten structure
      return SerializedDirectedGraph
    public class SerializedDirectedGraph implements DirectedGraph
      // a flat structure that can be used to rebuild the hierarchical one
    Object readResolve() throws ObjectStreamException;
      // rebuild hierarchy
      return LocalDirectedGraph
    }Perhaps traverse the original graph and write a linear structure of the individual objects and some info about what level they are at. Implement writeReplace and place this code in it, returning a SerializedDirectedGraph. At the receiving end implement readResolve and reconstruct the original, returning a LocalDirectedGraph. Everywhere else in your code refer to your objects by the interfaces. Because the JDK handles the cyclic references thing you still get the original object graph, you are just intervening to make the structure more serialization-friendly.
    Check out [url http://java.sun.com/j2se/1.4.2/docs/guide/serialization/spec/output.html#wp5324]this section of the serialization spec. I've used this feature for different reasons, as well as other hooks available in Serialization, and am very impressed with the whole implementation.

  • Error message while executing a SWF File

    Hi All,
    Iam trying to execute a SWF file which has its actionscript
    written in AS3. When i execute this, I am getting an error message
    which is as follows
    Verify Error 1030# Stack Depth unbalanced 1 != 0.
    Can anyone tell me what could be the root cause?
    Thanks in advance,
    Prabakaran Srinivasan.

    Hi All,
    I am able to find the root cause for this. For AS 3 classes,
    while parsing the ABC code, every method body will be a set of
    instructions in which each instruction will have an offset to it.
    This offset will be useful to mark the target for branching
    instructions like if, while etc.... Because, these instructions
    contains targetoffset as a parameter to which the instruction has
    to jump when the condition becomes true or false. The process what
    i am doing is i do some code injection to replace the URLRequest
    calls. The flash file in which i got this error, i did replace the
    URLRequest call to my own method call and this code was being
    wrapped up by an IF block. Because of the code injection, i need to
    update the offset of the instructions with the difference offset
    value. I did this, but i missed the jumpoffset parameter of the if
    block wrapping my injected code which was the root cause. I did fix
    this...
    Thanks,
    Prabakaran Srinivasan.

  • ADF desktop integration issue

    i have created a application and published to weblogic successfully, but when i tried to run my integrated excel workbook, i got following errors. how to resolve this issue ?
    ADFDI-00134: An attempt to connect to the web application has failed.
    ADFDI-00501: An unexpected status: 500 (InternalServerError) was returned from the server while requesting the URL: http://localhost:7101/myDITest/adfdiRemoteServlet
    ~~~~~~~~~~
    ConnectionFailedException: ADFDI-00134: An attempt to connect to the web application has failed.
    Source: adfdi-excel-runtime
    Stack:
    at oracle.adf.client.windows.excel.runtime.WebAppLogin.GetAuthenticationMode()
    at oracle.adf.client.windows.excel.runtime.WebAppLogin.Login()
    at oracle.adf.client.windows.datamanager.ADFBindingContext.AttemptLogin(Boolean maybeHadSession)
    at oracle.adf.client.windows.datamanager.ADFBindingContext.SyncModel(BindingContainer bc, String contentType)
    at oracle.adf.client.windows.datamanager.BindingContainer.ReloadMetadata()
    at oracle.adf.client.windows.datamanager.BindingContainer.LoadMetadata()
    at oracle.adf.client.windows.excel.runtime.DIWorksheet.InitializeComponents(Boolean isFirstLoad)
    at oracle.adf.client.windows.excel.runtime.DIWorksheet.Initialize(Boolean initializeUI)
    Inner:
    UnexpectedHttpStatusException: ADFDI-00501: An unexpected status: 500 (InternalServerError) was returned from the server while requesting the URL: http://localhost:7101/myDITest/adfdiRemoteServlet
    Source: adfdi-excel-runtime
    Stack:
    at oracle.adf.client.windows.excel.runtime.WebAppLogin.GetAuthenticationMode()
    yong

    There is some kind of configuration problem with your web application.
    First, you should report the version of ADFdi you are using.
    Next, you should verify the configuration against the guide.
    http://docs.oracle.com/cd/E24382_01/web.1112/e16180/prep_dev.htm#sthref25
    Next, you should perform some diagnostic steps.
    http://docs.oracle.com/cd/E24382_01/web.1112/e16180/ap_desk_integ_troubleshoot.htm#CHDIBEEE
    HTH
    Alex

  • C# interop get Step Name

    I am attempting to use a C# code module in order to read the calling step's name. However, my code only every returns "Step" as the name of the object (regardless of what the step is actually called in the sequence). Note that I have also tried doing the same thing to get the calling sequence name - and it always returns "Sequence". Where am I going wrong? Here is the code: (please see attachment for complete source and example TestStand sequence in the "Debug" folder.
    using System;
    using System.Collections.Generic;
    using System.Text;
    using NationalInstruments.TestStand.Interop.API;
    using System.Windows.Forms;
    namespace Test
        public class TestClass
            public void TestMethod(SequenceContext thisContext)
                PropertyObject pObj = thisContext.AsPropertyObject();
                PropertyObject stepObj;
                stepObj = pObj.Evaluate( "Step" );
                MessageBox.Show(stepObj.Name);
    As a bit of background, I am trying to retrieve the name of the calling step and the name of all Sequence calls all the way up the stack to the root. This same methodology works using Expression steps, but I want to hide all the mess into a single code module. Any ideas would be appreciated! 
    Thanks,
    Phil
    Solved!
    Go to Solution.
    Attachments:
    Test.zip ‏16 KB

    Hi Ray,
    Thanks for the advice. Unfortunately, I think I made my example a little too simplistic! Your solution is perfect for the Step Name case, unfortunately it will not work for what I am trying to do. I am writing a custom result logger that is called from the ProcessModelPostResultListEntry callback, and want to check whether the "RecordResult" option is enabled on all of the SequenceCall steps in the stack and whether each Sequence in the stack has the "RecordResults" option enabled. (Basically, Result Recording must be enabled at all levels for the result to be logged). You may think that the ProcessModelPostResultListEntry callback would only get called if this condition is met - unfortunately it is only affected by the most nested combination of the Step's "RecordResult" and the Sequence's "RecordResults" properties. Therefore, frustratingly, I need to check all the way up the stack back to the ProcessModel. The reson why this is more complex is that the Step and Sequence property objects further up the stack can only be accessed by using the Evaluate() Method, as opposed to the lowest level in the stack which can be accessed via thisContext.Step and thisContext.Sequence.
    Anyway, I worked it out in the end: Expressions within TestStand enable you to take a number of API shortcuts which are not available when using the API in another language - hence why I was able to use expressions like:
    Locals.SequenceRef = Evaluate( "RunState.Caller.RunState.Caller.Sequence" ),
    Locals.SequenceName = SequenceRef.Name
    Locals.SequenceRecResult = SequenceRef.RecordResults
    whereas similar code in C# did not work as expected (note that the RunState.Caller string above is actually built dynamically depending on the call stack depth).
    Being more explicit in C# does work correctly though:
    seqObj = pObj.Evaluate( "RunState.Caller.RunState.Caller.Sequence" );
    SequenceName = seqObj.Evaluate( "Name" ).GetValString("", 0 );
    SequenceReqResults = seqObj.Evaluate( "RecordResults" ).GetValBoolean( "", 0 );
    Although, in the process of writing this response, I have just found the following property:
    SequenceContext.CallerDiscardsResults
    "Returns whether any sequence in the call stack instructs TestStand to disable results or if any calling step up the call stack instructs TestStand to not record results"
    Typical! I think this may be an easier route to use!!!
    Thanks anyway,
    Phil
    Message Edited by monkeyslikebananas on 03-11-2009 01:40 AM
    Message Edited by monkeyslikebananas on 03-11-2009 01:41 AM

  • CRVS2010 Beta - Error in report with currency field in WPF viewer

    When using CRVS2010 with one of my applications I discovered that an InvalidOperationException happens everytime I try to load a report that contains a Currency Field database entry in the WPF viewer.
    To be sure, I made a simple report just with the Currency field and the error happens the same way.
    The exception that I receive is:
    This Pop operation has no corresponding Push to remove from the stack because the stack depth of the DrawingContext is zero.
    And the Stack trace is:
    at System.Windows.Media.RenderDataDrawingContext.Pop()
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawFieldObjectInstance(FieldObjectInstance fieldObjectInstance, VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawReportObjectInstance(ReportObjectInstance instance, VisualCollection visuals, Rect sectionClipRect)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.drawSectionInstance(SectionInstance section, VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageRender.Render(VisualCollection visuals)
       at SAPBusinessObjects.WPF.ViewerShared.PageView.Render()
       at SAPBusinessObjects.WPF.ViewerShared.PageView.set_PageObj(PageObject value)
       at SAPBusinessObjects.WPF.Viewer.DocumentView.ShowNthPage(Int32 PageNumber, Boolean hasAnimation)
       at SAPBusinessObjects.WPF.Viewer.ReportAlbum.OnCreateNewDocumentViewComplete(CreateNewDocumentArgs args)
       at SAPBusinessObjects.WPF.Viewer.DelegateMarshaler.<>c__DisplayClass6`1.<Invoke>b__4(Object )
    This problem happens in the WPF viewer, but not in the WinForms viewer.
    Please, if you know, tell me what I am doing wrong.

    This seems to be a bug in the software.  We will provide a fix in the final release. 
    -Mandeep

  • Web service data control for asynchronous bpel process

    I have an async BPEL process that I want to call from a JSP page. I followed the tutorial for creating a data control for web services. When the DC was created, it created an initiate operation that requires the ReplyTo and MessageID. I thought these are internal to the runtime stack, so why are they part of the data control? How do I get around it?
    Thanks,
    Rico

    http://blogs.oracle.com/shay/2010/05/updateinsert_with_adf_web_serv.html

  • Abap classes in NW 2004s

    Hi everybody!
    We have just migrated or BiW 3.1 to 7.0 (NW 2004s). For 3.1 version, we created some templates with Web Application Designer. These templates were formatted either by using stylesheets (ccs) or ABAP classes depending on the necessities. Now we are trying to create templates with the version 7.0 but the ABAP classes we used to use are not working.
    My questions are:
    Are not ABAP classes working anymore? Does anybody know how to deal with it? Which is the proper way to implement this issue in the new version?
    Greetings from Spain.

    Table classes has been removed from BI 7.
    Look at Faq-
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/cea68c65-0901-0010-f5a4-fd34189d8078
    The BEx Web Design API for Tables (table interface) and related customized ABAP coding that was available within the ABAP Web runtime is not available in the Java Web runtime. The enhanced standard capabilities should dramatically reduce the need for customer-specific coding. However, in order to ensure that customers can still benefit from the BEx Web Design API for Tables (table interface), we continue to ship the ABAP Web runtime as a fully supported runtime stack, in addition to the Java Web runtime.
    In some cases, you may want to combine the benefits of the new Java Web runtime with the advantages of customizable coding, and it would be useful to have a customized coding option in the Java Web runtime.
    Therefore, in the next major SAP NetWeaver Release after SAP NetWeaver 2004s, SAP will provide a Java-based interface that can offer additional flexibility for customized coding.
    SAP Note Number: 931395
    Hope it Helps
    Chetan
    @CP..

  • Relationship between Dynamic Memory Heap and Heap Data Structure

    This question is not strictly related to Java, but rather to programming in general, and I tend to get better answers from this community than any where else.
    Somehow, my school and industry experience have somehow not given me the opportunity to explore and understand heaps (the data structure), so I'm investigating them now, and in particular, I've been looking at applications. I know they can be used for priority queues, heap sorts, and shortest path searches. However, I would have thought that, obviously, there must be some sort of relationship between the heap data structure, and the dynamic memory heap. Otherwise, I can think of no good reason why the dynamic memory heap would be named "heap". Surprisingly, after searching the web for 90 minutes or so, I've seen vague references, but nothing conclusive (trouble seems to be that it's hard to get Google to understand that I'm using the word "heap" in two different contexts, and similarly, it would not likely understand that web authors would use the word in two different contexts).
    The Java Virtual Machine Spec is silent on the subject, as "The Java virtual machine assumes no particular type of automatic storage management system, and the storage management technique may be chosen according to the implementor's system requirements."
    I've seen things like:
    [of dynamic memory] "All the blocks of a particular size are kept in a sorted linked list or tree (I extrapolate that sorted tree could imply heap)"
    [of dynamic memory] "The free and reserved areas of memory are maintained in a data structure similar to binary trees called a heap"
    [of dynamic memory] "This is not related to the heap data structure"
    [of dynamic memory] "Not to be confused with the data structure known as a "heap"
    [of data structure] "Not to be confused with the dynamic memory pool, often known as TheHeap"
    At this point, I've come to surmise that some (but not all) memory management algorithms use heaps to track which (pages? blocks? bytes?) of memory are used, and which are not. However, the point of a heap is to store data so that the max (or min) key is at the root of the heap. But we might want to allocate memory of different sizes at different times, so it wouldn't make sense to key on the amount of available memory in a particular region of the free store.
    I must assume then that there would be a different heap maintained for each size of memory block that can be allocated, and the key must have something to do with the attractiveness of the particular memory block in the heap (perhaps the lowest address, resulting, hopefully, in growing the free store space less often, leaving more space for the stack to grow, or perhaps keyed based on the fragmentation, to hopefully result in less fragmentation, and therefore more efficient use of the memory space, or perhaps based on page boundaries, keeping as much data in the same page as possible, etc).
    So at this point, I have a few questions I've been unable to resolve completely:
    1. Am I correct that the heap was so named because (perhaps at one point in time), a heap is/was commonly used to track the available memory in the free store?
    2. If so, would it be correct that there would be a heap per standard block size?
    3. Also, at what level of granularity would a heap typically be used (memory page, memory blocks, individual words (4-bytes))?
    4. What would be the most likely property one would use as a key. That is, what makes the root item on the heap ideal?
    5. Would a industrial strength system like the jvm use a (perhaps modified or tuned) heap for this sort of task, or would this typically be too naive for an real world solution today?
    Any insight would be awesome!
    Thanks,
    A.

    jschell wrote:
    I think you are not only mixing terms but domains.
    For starters the OS allocs memory. Applications, regardless of language, request memory from the OS and use it in various ways.
    There are many variations of the term "heap" like the following.
    [http://en.wikipedia.org/wiki/Heap_(data_structure)]
    [http://en.wikipedia.org/wiki/Dynamic_memory_allocation]
    A java VM will request memory from the OS (from a 'heap') and use it in its application 'heap' (C/C++) and then create the Java 'heap'. There can be variations of that along the way that can and likely will include variations of how each heap is used, potentially code that creates its own heap, and potentially other allocators which use something which is not a heap.This last part, I find a bit confusing. By "use something which is not a heap", do you mean the heap data structure, or the dynamic memory pool meaning of heap? If the former, then you would be implying that it would be common for a heap data structure to be used to manage the heap dynamic memory pool. If the latter, what would this "something which is not a heap" be? The best definition of "heap" I've found simply states that it is a pool of memory that can be dynamically allocated. If there is some other way of allocating dynamic memory, then it would suggest that the previous definition of "heap" is incomplete.
    >
    So to terms.
    1. Am I correct that the heap was so named because (perhaps at one point in time), a heap is/was commonly used to track the available memory in the free store?Which 'heap'? The VM one? It is probably named that because the implementors of the Sun VM were familar with how C++ and Smalltalk allocated memory.Okay, but that begs the question, was the heap in C++ and/or Smalltalk so named for the above queried reason?
    >
    2. If so, would it be correct that there would be a heap per standard block size?Not sure what you are referring to but probably a detail of the implementation. And since there are different levels the question doesn't mean much.
    However OS allocations are always by block if that helps. After that it requires making the question much, much more specific.
    3. Also, at what level of granularity would a heap typically be used (memory page, memory blocks, individual words (4-bytes))?Again not specific enough. A typical standard implementation of heap could not be at the word level. And it is unlikely, but not impossible, that variations would support word size allocations.
    The VM heap might use word boundaries (but not size), where the application heap certainly does (word boundary.)My understanding of it is that the application would request blocks from the OS, and then something like malloc would manage the memory within the allocated blocks. malloc (or whatever equivalent Java uses) would have to keep track of the memory it has allocated somehow, and I would think it would have to do this at the word level, since it's most commonly going to allocate memory at the word level to be references to other objects, etc.
    So I guess my question here would really be, if the dynamic memory heap is so named because there has been a memory management strategy that relied upon a heap data structure (which I've found no proof, but have found some suggestive literature), then would that probably have applied at the OS Page Fault level, tracking allocated blocks, or would that have applied at the malloc level, allocating individual words as necessary?
    >
    4. What would be the most likely property one would use as a key. That is, what makes the root item on the heap ideal?"Key" is not a term that will apply in this discussion.
    You appear to be referring to strategies for effective allocation of memory such as allocations from different regions by size comparison.
    It is possible that all levels might use such an allocator. General purpose applications do not sort allocations though (as per your one reference that mentions 'key'.) Sorry, I got the term "key" from an article I read regarding heaps, that indicates that a "key" is used to sort the elements, which I guess would be a more generalized way to make a heap than assuming a natural ordering on the elements in the heap. I'm not sure if the terminology is standard.
    >
    5. Would a industrial strength system like the jvm use a (perhaps modified or tuned) heap for this sort of task, or would this typically be too naive for an real world solution today?Again too indefinite. The Sun VM uses a rather complicated allocator, the model for which originated after years of proceeding research certainly in Smalltalk and in Lisp as well, both commercially and academically.
    I am sure the default is rules driven either explicitly or implicitly as well. So it is self tuning.
    There are command line options that allow you to change how it works as well.I guess perhaps I could attempt to clarify my initial question a bit.
    There is a 1:1 correspondence between the runtime stack, and a stack data structure. That is, when you call a function, it pushes a stack frame onto the runtime stack. When you return from a function, it pops a stack frame from the runtime stack. This is almost certainly the reasons the runtime stack is named as it is.
    The question is, is there or has there ever been a 1:1 correspondence between some aspect of the dynamic memory heap or how it is managed, and a heap data structure? If so, it would explain the name, but I'm a bit puzzled as to how a heap data structure would be of assistance in creating or managing the dynamic memory heap. If not, on the other hand, then does anybody know where the name "heap" came from, as it applies to the dynamic memory pool?
    A.

Maybe you are looking for

  • Radar Charts SSRS

    Hi All, I have requirement to develop a report like below image. Is to possible to develop this kind of reports in SQL Server Reporting services 2008 r2. I have tried with one example but the major grid lines shows only circle it is not changing to b

  • Problem with populating list

    Gurus, This is the record group query "Select country_desc from country order by country_id" and I am using this record group with a populate built in .. But I amnt able to see the records in the list item .. I am using this code in when new form ins

  • HT2204 verify on iTunes store

    verify on iTunes store id

  • [Solved] ORA-02063: preceding line from [databaselink name]

    Friends When I run below query, it works and returns records. ===>> SELECT R1.TRANSACTION_ID, R1.CREATION_DATE, R1.TRANSACTION_TYPE, R1.QUANTITY, R1.PRIMARY_UNIT_OF_MEASURE UOM, R1.CURRENCY_CODE, R1.PO_UNIT_PRICE, R1.PO_HEADER_ID, R1.PO_LINE_ID, P1.C

  • Update failure when adding email

    Hi, I have a blackberry curve9360, I added my work email on my personal phone, and when I got my work phone I signed in with my personal blackberry ID, which synced my personal emails and work emails.  I decided to remove my personal email from my wo