Re: C-objects and memory use

2017-07-24 Thread Peter Bozek via 4D_Tech
On Tue, Jul 25, 2017 at 1:41 AM, Kirk Brooks via 4D_Tech <
4d_tech@lists.4d.com> wrote:

> I want to make sure my understanding about how c-objects are handled in 4D
> memory. Mainly because it seems this understanding is cobbled together from
> a number of different sources few of which I can easily find again. So...
>
>

Kirk,

Here is how I understand objects. Not sure if it is correct, and while I
use object a bit, I cannot claim I tested all my assertions, so they can be
wrong. Anyway, it may be interesting to compare our views:


> 1) c-objects are created within the 3 4D scopes: IP, process or local.
>

As I understand it, there is one 'heap' of objects, what means all objects
are IP (where by object I mean here data structures containing data).
Object variables are local, process or IP, but they are just references to
this global object heap.

You mention that variables are something like pointers, I prefer to
consider them a references (like 'fifth object from the right') for the
following reason:
Objects are ref-counted. This means that each (global) object keeps count
how many variables (local, process and IP) is referencing this object. When
that count get to 0, object is deleted.


>
> 2) but they share some characteristics with hLists and menuRefs in that
> once created they can be referred to by different instances. For example,
> if I create an process object called "prosObj" as:
>
> { obj1: {name: Kirk, ID: 1234},
>
>obj2: {name: Joe, ID: 5678}}
>
> In this case, object heap will contain three objects, each with refcount
of 1:
{name: Kirk, ID: 1234}
{name: Joe, ID: 5678}
{obj1: reference to first object, obj2: reference to second object}


>
> I can create a local obj as:
>
> $obj:=OB GET(prosObj;"obj1")
>

you create a local (object) variable referencing first object, and refcount
of this object is increased to 2.

3) My first point of clarification is that $obj is simply referencing
> prosObj so it's not significantly increasing the amount of memory used.
>

yes, object variables are just references to objects (data structures
containing object data.)

>
> 4) Conversely if I created $obj using the copy command it would. So
>
> $obj:=OB COPY(OB GET(prosObj;obj1))
>
> would create a full copy of obj1 and take up more memory.
>

More interesting case is what happens if you copy the main object
containing references to other objects. I believe references are not
coppied, it means you will get another object with object references to
original objects (And refcounts of original objects will be increased.


>
> 5) This referencing feature also applies to objects in arrays. It's easy to
> discover this inadvertently:
>
> ARRAY OBJECT($aObjs;0)
>
> OB SET($obj;key;"new value")
>
> APPEND TO ARRAY($aObjs;$obj)
> APPEND TO ARRAY($aObjs;$obj)
> APPEND TO ARRAY($aObjs;$obj)
>
> $aObjs has 3 element each containing: {key;"new Value"}.
>

As I understand it, you have only one object  {key;"new value"} with for
variables referencing it: $obj, $aObjs{1}; $aObjs{2} and $aObjs{3}.


> If I modify $obj:
>
> OB SET($obj;key;"defined value")
>
> ​each element of $aObjs is now ​
>  {key;"new Value"}
>

you mean {key;"defined value"}?


> ​Again, I'm assuming $obj only exists in memory one time with each element
> of $aObjs referring to it.
>

Yes, this is my understanding as well.


> 6) I can clear $obj without erasing the referenced values by calling:
>
> $obj:=JSON PARSE("{}")
>

yes, this creates a new (empty) object storage and stores reference to it
into $obj, and decreases refcount to original object by one. In this
example, original object data are still references by three array elements.
When method ends and local array $aObjs is cleared, the data will be
cleared.


> 7) ​And unlike menus and hLists ​the memory occupied by $obj is released
> when the process end.
>

No, objects are released - in the sense the memory occupied by it is
cleared - when their refcount is 0. Ending method clears references from
local object variables, ending process clears references from process
variables. But if you have


C_OBJECT($obj)
OB SET($obj;key;"value")

<>ipObj:=$obj

object {key;"value"} will not be cleared when method or process ends.

​
>
> 8) Passing objects as parameters is essentially equivalent to passing
> pointers to c-obj vars EXCEPT when working with a method called with
> Execute on server - object references don't propagate when moving between
> the twin and local process. So let's say myMethod
> does this:
>

Yes, when you pass object to server process or method executed on server,
object is serialized, send to other side and there recreated.

The same seems to hold if you pass object to worker, but this I have not
tested (but if it would not be true, we would have values shared with
workers.)



>  ​
> SET($1->;"name";"Kirk")
>
> ​then myMethod will work the same way on the client or EOS. However I
> suspect the time to dereference a pointer adds some time on the client side
> that wouldn't b

Re: C-objects and memory use

2017-07-24 Thread David Adams via 4D_Tech
Kirk,

This is the sort of question that would most likely take someone from 4D
Engineering to answer. They don't participate on this list, so I guess that
you can try the Forums or open a Tech Support case (?).

Please post back here if you get any reliable information as not all of us
follow the Forums.
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

C-objects and memory use

2017-07-24 Thread Kirk Brooks via 4D_Tech
I want to make sure my understanding about how c-objects are handled in 4D
memory. Mainly because it seems this understanding is cobbled together from
a number of different sources few of which I can easily find again. So...

1) c-objects are created within the 3 4D scopes: IP, process or local.

2) but they share some characteristics with hLists and menuRefs in that
once created they can be referred to by different instances. For example,
if I create an process object called "prosObj" as:

{ obj1: {name: Kirk, ID: 1234},

   obj2: {name: Joe, ID: 5678}}


I can create a local obj as:

$obj:=OB GET(prosObj;"obj1")

In this case $obj can be thought of as a pointer to prosObj.obj1 because if
I change the values in $obj these changes will also be made in ProsObj. So

OB SET($obj;"name";"Xavier")

​and then look at prosObj I'll see:

{ obj1: {name: Xavier, ID: 1234},

   obj2: {name: Joe, ID: 5678}}

​

3) My first point of clarification is that $obj is simply referencing
prosObj so it's not significantly increasing the amount of memory used.

4) Conversely if I created $obj using the copy command it would. So

$obj:=OB COPY(OB GET(prosObj;obj1))

would create a full copy of obj1 and take up more memory.

5) This referencing feature also applies to objects in arrays. It's easy to
discover this inadvertently:

ARRAY OBJECT($aObjs;0)

OB SET($obj;key;"new value")

APPEND TO ARRAY($aObjs;$obj)
APPEND TO ARRAY($aObjs;$obj)
APPEND TO ARRAY($aObjs;$obj)

$aObjs has 3 element each containing: {key;"new Value"}.

If I modify $obj:

OB SET($obj;key;"defined value")

​each element of $aObjs is now ​
 {key;"new Value"}
​:​


​Again, I'm assuming $obj only exists in memory one time with each element
of $aObjs referring to it.

6) I can clear $obj without erasing the referenced values by calling:

$obj:=JSON PARSE("{}")

7) ​And unlike menus and hLists ​the memory occupied by $obj is released
when the process end.
​

8) Passing objects as parameters is essentially equivalent to passing
pointers to c-obj vars EXCEPT when working with a method called with
Execute on server - object references don't propagate when moving between
the twin and local process. So let's say myMethod
does this:

 OB
​ ​
SET($1;"name";"Kirk")


I can execute this method locally myMethod($obj) and $obj = {"name";"Kirk"}

If I set the EOS parameter (and run it on the server) no errors are thrown
but the client side version of $obj doesn't change.

​If I change myMethod to take a pointer;

​OB
 ​
SET($1->;"name";"Kirk")

​then myMethod will work the same way on the client or EOS. However I
suspect the time to dereference a pointer adds some time on the client side
that wouldn't be required by simply accessing the object directly. ​


For these examples the memory use is trivial, of course. But as I coming to
appreciate how great c-objects are for managing a lot of data in memory I
can see a time when I might be working with significant memory allocations
where these things can really matter.


-- 
Kirk Brooks
San Francisco, CA
===

*The only thing necessary for the triumph of evil is for good men to do
nothing.*

*- Edmund Burke*
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: v13 - Host methods, and components

2017-07-24 Thread Keisuke Miyako via 4D_Tech
METHOD GET NAMES
http://doc.4d.com/4Dv16/4D/16.1/METHOD-GET-NAMES.301-3376032.en.html
will return a list of shared method names.

> 2017/07/25 5:47、Chip Scheide via 4D_Tech <4d_tech@lists.4d.com> のメール:
> if not, is there some way to determine if a method exists in the host, from a 
> component?




**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: v13 - Host methods, and components

2017-07-24 Thread Chip Scheide via 4D_Tech
i did not see this option initially.
I have a follow up question...

I am playing with this command.
I have the following code:
$x:=METHOD Get path(Path Project method;"does not exist")
TRACE
$x:=METHOD Get path(Path Project method;"url_Errtxt_Init")
TRACE

the first call to get method path - the method does not exist, in the 
second it does.
There is no difference in return value (the method name) nor is an 
error generated from the first call.
I can get an error to be generated by calling METHOD GET MODIFICATION 
DATE, but the documentation says they an error should be generated if 
the method does not exists when I call METHOD Get path.

Ideas?
Thanks

On Mon, 24 Jul 2017 20:55:34 +, Keisuke Miyako via 4D_Tech wrote:
>> Can I, form a component, use "Get Method Paths" to determine if a 
>> method exists in the host?
> 
> yes, you pass the optional *
> 
> http://doc.4d.com/4Dv15/4D/15.4/METHOD-GET-PATHS.301-3273681.en.html
> 
>> Additionally, Am I right, I can call a host database method from a 
>> component (as long as I know it exists)?
> 
> yes as long as the method is shared
> 
> http://doc.4d.com/4Dv15/4D/15.4/EXECUTE-METHOD.301-3274817.en.html
> 
> 
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: v13 - Host methods, and components

2017-07-24 Thread Keisuke Miyako via 4D_Tech
> Can I, form a component, use "Get Method Paths" to determine if a method 
> exists in the host?

yes, you pass the optional *

http://doc.4d.com/4Dv15/4D/15.4/METHOD-GET-PATHS.301-3273681.en.html

> Additionally, Am I right, I can call a host database method from a component 
> (as long as I know it exists)?

yes as long as the method is shared

http://doc.4d.com/4Dv15/4D/15.4/EXECUTE-METHOD.301-3274817.en.html



**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

v13 - Host methods, and components

2017-07-24 Thread Chip Scheide via 4D_Tech
Can I, form a component,
use "Get Method Paths" to determine if a method exists in the host?

if not, is there some way to determine if a method exists in the host, 
from a component?

Additionally, Am I right, I can call a host database method from a 
component (as long as I know it exists)?
Thanks
Chip
---
Gas is for washing parts
Alcohol is for drinkin'
Nitromethane is for racing 
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Serious 4D Internet commands issue in v15.4 with SMTP on Mac OS X

2017-07-24 Thread Paul Lovejoy via 4D_Tech
Hi again,

I just commented out the lines

 $err:=SMTP_SetPrefs (1;1;0)
$err:=SMTP_Charset (1;1)

and it appeared to solve the problem. So it would appear the internet commands' 
default behavior is different in v15.

Thanks!


Paul

> Le 24 juil. 2017 à 14:19, Jeffrey Kain via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> What character set are you using?
> 
>> On Jul 24, 2017, at 7:33 AM, Paul Lovejoy via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> The mails are sent to the desired destination  but the subject and the body 
>> are often truncated, with a “?” at the end of the subject or body where the 
>> rest of the text should be. In most cases, the texts are generated 
>> automatically from records in the database. The subject and body are 
>> generated automatically. 
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Serious 4D Internet commands issue in v15.4 with SMTP on Mac OS X

2017-07-24 Thread Paul Lovejoy via 4D_Tech
Hi Jeffrey,

Good question. We have always done this 

 $err:=SMTP_SetPrefs (1;1;0)
$err:=SMTP_Charset (1;1)


In this database. I would guess  that’s been there for 20 years in legacy code 
I never touched…

Paul


> Le 24 juil. 2017 à 14:19, Jeffrey Kain via 4D_Tech <4d_tech@lists.4d.com> a 
> écrit :
> 
> What character set are you using?
> 
>> On Jul 24, 2017, at 7:33 AM, Paul Lovejoy via 4D_Tech <4d_tech@lists.4d.com> 
>> wrote:
>> 
>> The mails are sent to the desired destination  but the subject and the body 
>> are often truncated, with a “?” at the end of the subject or body where the 
>> rest of the text should be. In most cases, the texts are generated 
>> automatically from records in the database. The subject and body are 
>> generated automatically. 
> 
> **
> 4D Internet Users Group (4D iNUG)
> FAQ:  http://lists.4d.com/faqnug.html
> Archive:  http://lists.4d.com/archives.html
> Options: http://lists.4d.com/mailman/options/4d_tech
> Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
> **

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Re: Serious 4D Internet commands issue in v15.4 with SMTP on Mac OS X

2017-07-24 Thread Jeffrey Kain via 4D_Tech
What character set are you using?

> On Jul 24, 2017, at 7:33 AM, Paul Lovejoy via 4D_Tech <4d_tech@lists.4d.com> 
> wrote:
> 
> The mails are sent to the desired destination  but the subject and the body 
> are often truncated, with a “?” at the end of the subject or body where the 
> rest of the text should be. In most cases, the texts are generated 
> automatically from records in the database. The subject and body are 
> generated automatically. 

**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**

Serious 4D Internet commands issue in v15.4 with SMTP on Mac OS X

2017-07-24 Thread Paul Lovejoy via 4D_Tech
Hi everyone,

Last week we upgraded a v12 database to v15. Most things are working perfectly 
but we have some serious issues sending emails with the SMTP commands. 

We have been sending hundreds of thousands of emails successfully with our 
application over the years. Now we are encountering a serious issue.

The mails are sent to the desired destination  but the subject and the body are 
often truncated, with a “?” at the end of the subject or body where the rest of 
the text should be. In most cases, the texts are generated automatically from 
records in the database. The subject and body are generated automatically. 

Has anyone seen this? Are there known issues with the internet commands in 
v15.4?


Cheers,


Paul
**
4D Internet Users Group (4D iNUG)
FAQ:  http://lists.4d.com/faqnug.html
Archive:  http://lists.4d.com/archives.html
Options: http://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:4d_tech-unsubscr...@lists.4d.com
**