Re: Fortran and .NET (C#)



In article <Vvh_e.24109$nq.10607@lakeread05>,
"apm" <Contributor@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:

> "Richard E Maine" <nospam@xxxxxxxxxxxxx> wrote in message
> news:nospam-0B071C.12183427092005@xxxxxxxxxxxxxxxxxxxxx

> > pointers (both in C and in Fortran)
> > are subject to memory leak problems. In contrast, you can't generate a
> > memory leak with a Fortran array that isn't a pointer, no matter how
> > hard you try.
>
> Both Fortran pointers and allocatable arrays allow dynamic allocation. It is
> the dynamic allocation that can lead to memory leaks.

That is an overly broad generalization which is false. You are
attempting to generalize your previous experience with a particular
style of dynamic memory allocation. The generalization doesn't hold.

Let me repeat for the second time (at least) in this thread, and not
counting many times in previous thready. You *CANNOT* leak memory
because of a user error with Fortran allocatable arrays. That is an
intentional part of the design of Fortran allocatables. It is so much a
part of the design, that if you managed to find a way to do it, I am
confident that it would be regarded as a bug in the standard and a fix
would be published. In the many times I have explained this, not once
has anyone come up with a code sample to contradict it.

Nor, I might add, can you leak memory because of a user error with
Fortran's dynamically allocated automatic arrays.

Memory leaks are not fundamental to dynamic allocation. They are a
"feature" of using pointers (or other similar things) for dynamic
allocation.

--
Richard Maine | Good judgment comes from experience;
email: my first.last at org.domain | experience comes from bad judgment.
org: nasa, domain: gov | -- Mark Twain
.



Relevant Pages

  • Re: INTERFACE problem
    ... I have an integer at Fortran side, pass it by reference to C function, treat here as pointer, allocate memory and this C-pointer at Fortran side now is an integer which has represents address allocated at C side. ... I did something like this many years ago to allow dynamic allocation ... Then it was converted into a subroutine with the arrays and ... it called the sub by way of Pascal with those "pointers". ...
    (comp.lang.fortran)
  • Re: Fortran and .NET (C#)
    ... In contrast, you can't generate a memory leak with a Fortran array that isn't a pointer, no matter how hard you try. ... You are attempting to generalize your previous experience with a particular style of dynamic memory allocation. ...
    (comp.lang.fortran)
  • Re: Matlab Vectorisation Speed - How is it done in c++?
    ... interleaf posting, see ... traffic is more of a problem than register allocation, ... Regarding the "abuse of pointers" I'm not sure what you're ... 250,000 lines of code (C and Fortran; ...
    (comp.soft-sys.matlab)
  • Re: Ten Commandments for Fortran Programming?
    ... Aren't this more general programming tips, rather than Fortran ones? ... check for allocation errors, so the code blows up when they fail. ... To me, pointers are as bad as GOTOs - just with data, instead of ...
    (comp.lang.fortran)
  • mem leaks in dcmqrscp
    ... memory leak reporting tools, such as Purify, to ... Distribution of leaked blocks ... Allocation location ...
    (comp.protocols.dicom)