开发者

Flex RemoteObject: Arrays with same values reference same memory

开发者 https://www.devze.com 2022-12-11 16:40 出处:网络
If I send remote data from Zend_Amf to Flex, if two array properties on the object have the same data values they are deserialized at the remote end with the same memory storage.

If I send remote data from Zend_Amf to Flex, if two array properties on the object have the same data values they are deserialized at the remote end with the same memory storage.

Example: AS3 object:

Snippet:

[RemoteClass(alias="TestVO")]
public class TestVO
{
  public var test1:Array;
  public var test2:Array;
}

When this receives remote data from Zend_Amf server, if the array data are identical it allocates the same storage to the two arrays.

Eg: From remote (ZendAMF) object I send:

$this->test1 = array("foo", "bar");
$this->test2 = array("foo", "bar");

When I debug the TestVO object in Flex debugger I get:

test1 Array(@597d779)

test2 Array(@597d779)

ie: they reference the same array object.

If I send from the 开发者_C百科remote server slightly different values for the 2 arrays:

$this->test1 = array("foo", "bar");

$this->test2 = array("bar", "foo");

In the Flex debugger the TestVO object now has two seperate arrays as you'd expect:

test1 Array(@54cb7e9)

test2 Array(@54cb741)

AMF output looks Ok, it always sends two seperate values for test1/test2 even if they have the same values, so I'm guessing it's the way Flex de-serializes this?

Any ideas? Thanks.


AMF does this to gain some compression over the wire. If you don't want this then you can switch to the AMF0 format instead of AMF3. But I'm not sure how to do that with ZendAMF.


Found bug ZF-7634 on Zend Framework implementation of AMF. It is serializing the arrays incorrectly.

http://framework.zend.com/issues/browse/ZF-7634

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号